security放行 spirng_Spring Boot中怎么放行Spring Security拦截的静态资源?

@Override

protected void configure(HttpSecurity http) throws Exception {

http.csrf() //跨站

.disable() //关闭跨站检测

.authorizeRequests() //验证策略

.antMatchers(WHITE_LIST).permitAll()

.anyRequest().authenticated() //默认其它的请求都需要认证

.and()

.formLogin()

.loginPage(SecurityConstants.LOGIN_PAGE)

.failureUrl(SecurityConstants.FAILURE_URL)

.permitAll()

.defaultSuccessUrl(SecurityConstants.DEFAULT_SUCCESS_URL, true)

.permitAll()

.and()

.exceptionHandling()

.accessDeniedPage(SecurityConstants.ACCESS_DENIED_PAGE);

/*

* 本次 json web token 权限控制的核心配置部分

* 在 Spring Security 开始判断本次会话是否有权限时的前一瞬间

* 通过添加过滤器将 token 解析,将用户所有的权限写入本次 Spring Security 的会话

*/

http.addFilterBefore(new JwtAuthenticationFilterListener(this.komsProperties),

UsernamePasswordAuthenticationFilter.class);

//禁用缓存

http.headers().cacheControl();

}

添加白名单

private static String[] WHITE_LIST;

.antMatchers(WHITE_LIST).permitAll()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值