我已经在安全性webflux中设置了http.formLogin()。disable()。
@Bean
SecurityWebFilterChain webFluxSecurityFilterChain(ServerHttpSecurity http) {
http
.securityMatcher(webExchangeMatcher)
.formLogin()
.disable()
.httpBasic()
.disable()
.exceptionHandling().accessDeniedHandler(deniedHandler)
.and().authorizeExchange()
.pathMatchers("/login/**", "/**/v2/api-docs").permitAll()
.anyExchange().authenticated()
.and().csrf().disable();
return http.build();
}
现在我的问题是如何在自定义登录界面中登录? 下一个代码没用
@RequestMapping(value = "/login/admin/web/login", method = RequestMethod.POST)
public Mono adminLogin(@RequestParam("username") String username, @RequestParam("password") String password) {
LoginAuthentication loginAuthentication = new LoginAuthentication(username, password);
UpmsUser upmsUser = upmsUserServiceApi.getByLoginName(loginAuthentication.getUsername());
return ReactiveSecurityContextHolder.getContext().flatMap(securityContext -> {
securityContext.setAuthentication(loginAuthentication);
return Mono.just(Result.success(upmsUser));
});
}
它不能返回upmsUser并且不运行securityContext.setAuthentication(loginAuthentication)