Я работаю над унаследованным приложением Spring MVC, и мне нужно передать токен _csrf в javascript, но после введения Spring-Security (в частности, аутентификации пользователя 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 из web.xml, потому что он должен быть создан с расширением WebSecurityConfigurerAdapter и в соответствии с этим ТАК вопрос $ {_ csrf.parameterName} и $ {_ csrf.token} возвращают ноль Я должен добавить заново, но, если я это сделаю, я получаю ошибку запуска (отсутствует springSecurityFilterChain).
Итак, вопрос в том, почему мой токен является нулевым, если я реализовал WebSecurityConfigurerAdapter и не отключил csrf?