修复关闭接口鉴权时,处于忽略地址中的接口不可用的问题
parent
a4328e3d4f
commit
3dfbc843ad
|
@ -38,7 +38,6 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!userSetting.isInterfaceAuthentication()) {
|
if (!userSetting.isInterfaceAuthentication()) {
|
||||||
// 构建UsernamePasswordAuthenticationToken,这里密码为null,是因为提供了正确的JWT,实现自动登录
|
|
||||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(null, null, new ArrayList<>() );
|
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(null, null, new ArrayList<>() );
|
||||||
SecurityContextHolder.getContext().setAuthentication(token);
|
SecurityContextHolder.getContext().setAuthentication(token);
|
||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
|
|
|
@ -72,21 +72,23 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public void configure(WebSecurity web) {
|
public void configure(WebSecurity web) {
|
||||||
|
if (userSetting.isInterfaceAuthentication()) {
|
||||||
ArrayList<String> matchers = new ArrayList<>();
|
ArrayList<String> matchers = new ArrayList<>();
|
||||||
matchers.add("/");
|
matchers.add("/");
|
||||||
matchers.add("/#/**");
|
matchers.add("/#/**");
|
||||||
matchers.add("/static/**");
|
matchers.add("/static/**");
|
||||||
matchers.add("/index.html");
|
matchers.add("/index.html");
|
||||||
matchers.add("/doc.html");
|
matchers.add("/doc.html");
|
||||||
matchers.add("/webjars/**");
|
matchers.add("/webjars/**");
|
||||||
matchers.add("/swagger-resources/**");
|
matchers.add("/swagger-resources/**");
|
||||||
matchers.add("/v3/api-docs/**");
|
matchers.add("/v3/api-docs/**");
|
||||||
matchers.add("/js/**");
|
matchers.add("/js/**");
|
||||||
matchers.add("/api/device/query/snap/**");
|
matchers.add("/api/device/query/snap/**");
|
||||||
matchers.addAll(userSetting.getInterfaceAuthenticationExcludes());
|
matchers.add("/record_proxy/*/**");
|
||||||
// 可以直接访问的静态数据
|
matchers.addAll(userSetting.getInterfaceAuthenticationExcludes());
|
||||||
web.ignoring().antMatchers(matchers.toArray(new String[0]));
|
// 可以直接访问的静态数据
|
||||||
|
web.ignoring().antMatchers(matchers.toArray(new String[0]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue