1
我在我的系统中两个角色:用户和管理如何通过登录注销用户(不是当前)?
管理员可以通过名字登出任何用户。
我该怎么做? 我需要的是这样的:
service.logoutUser(anotherUserName)
的配置是这样的:
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers
....
.formLogin()
.loginProcessingUrl("/api/login")
.successHandler(authenticationSuccessHandler)
.failureHandler(new SimpleUrlAuthenticationFailureHandler())
.and()
.rememberMe()
.key("...")
.rememberMeCookieName("...")
.userDetailsService(userDetailsService)
.and()
.csrf()
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
.and()
.logout()
.deleteCookies("JSESSIONID")
.logoutUrl("/logout")
.logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler())
.permitAll();
你能澄清为什么要使用空字符串代替密码? – gstackoverflow
我想你可能会知道https://stackoverflow.com/questions/46101537/use-sessionregistry-without-session-count-limit-for-user – gstackoverflow
你不需要密码,你正在尝试做什么。此外,您的代码不需要知道用户密码。密码只能由用户编写并加密。 – mario