Jue*_*ann 3 spring-security spring-webflux
使用SpringMVC和Spring Security,我可以实现一个像这样的Controller(在Java中):
@RestController
@RequestMapping("/auth")
class AuthController {
private final AuthService authService;
AuthController(AuthService authService) {
this.authService = authService;
}
@GetMapping("/roles")
Collection<String> findRoles(Authentication authentication) {
final Object principal = authentication.getPrincipal();
...;
}
}
Run Code Online (Sandbox Code Playgroud)
但是,在使用Spring WebFlux和Spring Security(包括反应性部件)时,我基本上如何org.springframework.security.core.Authentication
在处理程序类(或服务类)中注入对象?
有很多示例:https : //github.com/spring-projects/spring-security
此示例显示了如何在rest控制器的情况下获取Principal:
这一节说明了如何在webflux情况下获取Principal:
| 归档时间: |
|
| 查看次数: |
2242 次 |
| 最近记录: |