Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring Security w/LDAP注销can';不要删除会话_Java_Spring_Spring Security_Ldap_Logout - Fatal编程技术网

Java Spring Security w/LDAP注销can';不要删除会话

Java Spring Security w/LDAP注销can';不要删除会话,java,spring,spring-security,ldap,logout,Java,Spring,Spring Security,Ldap,Logout,我正在使用SpringBootStarter安全版本:“2.0.0”来保护RESTAPI。 另外,我正在登录LDAP服务器。我的登录工作正常,当我放置具有身份验证配置的端点时,浏览器会询问user/pass。 问题是,当我执行注销时,我可以重新输入需要身份验证的端点,我的意思是,如果请求是安全端点,则需要用户/通行证。如果我登录正常,API将显示端点的结果,但如果我执行注销,注销将显示成功,我将再次请求安全端点,但结果将在未登录的情况下显示。 另外,我配置了2个最大会话,当我执行两次注销时,我无

我正在使用SpringBootStarter安全版本:“2.0.0”来保护RESTAPI。 另外,我正在登录LDAP服务器。我的登录工作正常,当我放置具有身份验证配置的端点时,浏览器会询问user/pass。 问题是,当我执行注销时,我可以重新输入需要身份验证的端点,我的意思是,如果请求是安全端点,则需要用户/通行证。如果我登录正常,API将显示端点的结果,但如果我执行注销,注销将显示成功,我将再次请求安全端点,但结果将在未登录的情况下显示。 另外,我配置了2个最大会话,当我执行两次注销时,我无法再次登录,因为我收到了最大会话错误。 因此,在某种程度上,我的注销效果不好

这是我的代码:

@Configuration 
@启用Web安全性 公共类SecurityConfig扩展了WebSecurity配置适配器{

@凌驾 受保护的无效配置(HttpSecurity http)引发异常{

    http.
            httpBasic()
            .and().authorizeRequests()
            .antMatchers("/about/**","/hello/**","/logout/**","/logout-success","/login/**").permitAll() //Allow to all to this url
            .anyRequest().fullyAuthenticated()
            .and()
            .requestCache()
            .requestCache(new NullRequestCache())
            .and()
            .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER)
            .maximumSessions(2).expiredUrl("/login").maxSessionsPreventsLogin(true)
            .and()
    ;

    http.csrf().disable();
    http.headers().frameOptions().disable();

    //logout
    http.logout().deleteCookies("JSESSIONID").invalidateHttpSession(true).logoutUrl("/logout").logoutSuccessUrl("/logout-success");

}

@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {


    String ldapURL = "ldaps://xxxx";

    auth
            .ldapAuthentication()
            .userSearchFilter("xxx")
            .userSearchBase("xxxx")
            .groupSearchBase("xxxx")
            // .groupSearchFilter("member={0}")
            .contextSource()
            .url(ldapURL)
            .port(xxx)
            .managerDn("xxxx")
            .managerPassword("xxxx")
    ;

}

我发现了关于这一点的不同理论,最常见的理论是,您不能使用“基本”配置执行有效的注销:

http.httpBasic() 
因此,解决方案是使用表单页面来提供身份验证,或者使用Spring提供的
.formLogin()