feat: 新增sercurity的退出账号的配置
This commit is contained in:
parent
4d57b45a02
commit
45435f1cb4
@ -1,6 +1,7 @@
|
|||||||
package com.cnbm.admin.config;
|
package com.cnbm.admin.config;
|
||||||
|
|
||||||
import com.cnbm.admin.filter.JwtAuthenticationTokenFilter;
|
import com.cnbm.admin.filter.JwtAuthenticationTokenFilter;
|
||||||
|
import com.cnbm.admin.handler.LogoutSuccessHandlerImpl;
|
||||||
import com.cnbm.admin.service.impl.UserDetailsServiceImpl;
|
import com.cnbm.admin.service.impl.UserDetailsServiceImpl;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@ -45,6 +46,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private UserDetailsServiceImpl userDetailsService;
|
private UserDetailsServiceImpl userDetailsService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LogoutSuccessHandlerImpl logoutSuccessHandler;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure(HttpSecurity http) throws Exception {
|
protected void configure(HttpSecurity http) throws Exception {
|
||||||
@ -56,14 +60,19 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
.and()
|
.and()
|
||||||
.authorizeRequests()
|
.authorizeRequests()
|
||||||
// 对于登录接口 允许匿名访问
|
// 对于登录接口 允许匿名访问
|
||||||
.antMatchers("/login","/swagger/**","/v2/**",
|
.antMatchers("/login","/doLogout","/swagger/**","/v2/**",
|
||||||
"/doc.html",
|
"/doc.html",
|
||||||
"/swagger-resources/**",
|
"/swagger-resources/**",
|
||||||
"/swagger-ui/**",
|
"/swagger-ui/**",
|
||||||
"/webjars/**").anonymous()
|
"/webjars/**").anonymous()
|
||||||
// .antMatchers("/testCors").hasAuthority("system:dept:list222")
|
// .antMatchers("/testCors").hasAuthority("system:dept:list222")
|
||||||
// 除上面外的所有请求全部需要鉴权认证
|
// 除上面外的所有请求全部需要鉴权认证
|
||||||
.anyRequest().authenticated();
|
.anyRequest()
|
||||||
|
.authenticated()
|
||||||
|
// 退出登录,默认为/logout,这里修改接口地址为 /doLogout
|
||||||
|
.and().logout().logoutUrl("/doLogout")
|
||||||
|
// 设置退出登录成功处理程序,退出成功后返回JSON字符串
|
||||||
|
.logoutSuccessHandler(logoutSuccessHandler);
|
||||||
|
|
||||||
//添加过滤器
|
//添加过滤器
|
||||||
http.addFilterBefore(jwtAuthenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
|
http.addFilterBefore(jwtAuthenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
|
||||||
|
Loading…
Reference in New Issue
Block a user