使用springsecurity,jsp上的java${u csrf.token}始终为空
我正在开发一个传统的Spring MVC应用程序,我需要将_csrf令牌传递给javascript,但在引入Spring安全性(尤其是auth0用户身份验证)后,这两行始终为空:
<meta name="_csrf" content="${_csrf.token}"/>
<meta name="_csrf_header" content="${_csrf.headerName}"/>
这就是我如何覆盖配置(HttpSecurity http):
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
@PropertySources(@PropertySource("classpath:auth0.properties"))
@Order(-2 /* SecurityProperties.ACCESS_OVERRIDE_ORDER */)
public class AppConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/download/**", "/resources/**", "/plugins/**", "/js/**", "/css/**", "/colors/**", "/callback", "/login", "/loggedout").permitAll()
.antMatchers("/**").authenticated()
.and()
.logout().permitAll();
}
}
我已经从网上删除了DelegationgFilterProxy。xml,因为它应该被创建来扩展WebSecurity配置适配器,根据这个问题${_csrf.parameterName} and ${_csrf.token} return null,我应该重新添加,但如果我添加了,我会得到一个启动错误(缺少springSecurityFilterChain)
所以,问题是,如果我实现了WebSecurityConfigureAdapter,并且没有禁用csrf,为什么我的令牌为空
共 (0) 个答案