Spring基本身份验证注销无法在Firefox中运行

时间:2016-05-18 09:56:51

标签: javascript spring spring-security spring-boot

我正在尝试使用spring boot进行基本身份验证的站点注销。 以下解决方案仅适用于在Firefox中无法使用的Chrome

@EnableGlobalMethodSecurity(prePostEnabled = true)
@EnableWebSecurity
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    private UserDetailsService userDetailsService;

    @Override
    public void configure(HttpSecurity http) throws Exception {
        http
        .antMatcher("/**")
        .authorizeRequests()
            .antMatchers("/js/**", "/fonts/**", "/css/**", "/images/**", "/againlogin**")
            .permitAll()  
        .anyRequest()
            .fullyAuthenticated()
        .and().httpBasic()
        .and().csrf().disable();
    }


}

从html我触发注销的ajax调用

<a href="javascript:logoutUser()">Logout</a>

在Javascript中

   function logoutUser() {
    ClearAuthentication("/againlogin.html");    
}

function ClearAuthentication(LogOffPage) 
{
   var IsInternetExplorer = false;    

   try
   {
       var agt=navigator.userAgent.toLowerCase();
       if (agt.indexOf("msie") != -1) { IsInternetExplorer = true; }
   }
   catch(e)
   {
       IsInternetExplorer = false;    
   };

   if (IsInternetExplorer) 
   {
      // Logoff Internet Explorer
      document.execCommand("ClearAuthenticationCache");
      window.location = LogOffPage;
   }
   else 
   {
      // Logoff every other browsers
  $.ajax({
       username: 'unknown',
       password: 'WrongPassword',
           url: '/logout',
       type: 'GET',
       beforeSend: function(xhr)
               {
          xhr.setRequestHeader("Authorization", "Basic AAAAAAAAAAAAAAAAAAA=");
       },

               error: function(err)
               {
                  window.location = LogOffPage;
           }
  });
   }
}

我没有退出。

有些人可以帮我解决这个问题吗

0 个答案:

没有答案
相关问题