在项目网页点击logout
页面跳转失败,无法注销且无法跳转到登录页,后台日志如下:
[15:46:03:417] [172.25.114.36] [INFO] [http-n...exec-6] [ICMLoggingFilter] - Before request [GET /login?logout, client=172.25.114.35, session=51ed8f77-d7b3-414d-afff-cca0e95957c4]
[15:46:03:418] [172.25.114.36] [INFO] [http-n...exec-6] [ICMLoggingFilter] - REQUEST DATA : GET /login?logout, client=172.25.114.35, session=51ed8f77-d7b3-414d-afff-cca0e95957c4]
[15:46:32:250] [172.25.114.36] [INFO] [http-n...exec-6] [LoginFilter] - ##ctId from cookie:e66ab3e8afcc4fad8f232b5038d5efcb
[15:46:32:250] [172.25.114.36] [INFO] [http-n...exec-6] [SessionCacheUtils] - ##getCacheInfo() key:e66ab3e8afcc4fad8f232b5038d5efcb
[15:46:32:250] [172.25.114.36] [INFO] [http-n...exec-6] [HttpClient] - ##do post,url:http://wysso.uat4.livibank.local/DealLogState
[15:46:32:260] [172.25.114.36] [INFO] [http-n...exec-6] [SessionCacheUtils] - [LoginService>get userinfo result : {"auth":[{"commonName":"ALL","orderid":1,"authvalue":"/","appid":1252,"actionlevel":1,"id":2254,"state":1,"actionname":"ALL","ismenu":1,"parentid":2246,"actiondesc":"","authtype":"3"},{"commonName":"icm_server","orderid":0,"authvalue":"root","appid":1252,"actionlevel":1,"id":2246,"state":1,"actionname":"icm_server","ismenu":1,"parentid":-2147483648,"authtype":"1"}],"errorCode":"000000","userinfo":{"phone":"","level":"1","tel":"","remark":"","email":"2322@2.cjd","realname":"pei.yuan","username":"yuanpei"},"errorMsg":""}]
url强行跳转到 http://localhost:8080/login?logout
问题分析:
1.检查js跳转逻辑,确认前端页面逻辑正常;
2.检查拦截器是否有问题;
问题原因:
添加了Spring Security配置:
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.authorizeRequests()
.antMatchers("/error").permitAll()
.anyRequest().fullyAuthenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.successHandler(loginSuccessHandler)
.failureUrl("/login?error")
.and()
.httpBasic()
.and()
.logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.permitAll()
.logoutSuccessHandler(logoutSuccessHandler);
}
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response,
Authentication authentication) throws IOException, ServletException {
if (authentication != null) {
Log.debug(authentication.getName() + " LOGOUT !!");
}
setDefaultTargetUrl("/login?logout");
super.onLogoutSuccess(request, response, authentication);
}
如果不需要,直接删除即可解决问题;