我使用的是spring security和java config。
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/api/*").hasRole("ADMIN")
.and()
.addFilterAfter(new CsrfTokenResponseHeaderBindingFilter(), CsrfFilter.class)
.exceptionHandling()
.authenticationEntryPoint(restAuthenticationEntryPoint)
.and()
.formLogin()
.successHandler(authenticationSuccessHandler)
.failureHandler(new SimpleUrlAuthenticationFailureHandler());
我正在使用PostMan来测试我的REST服务。我成功地获得了'csrf token‘,并且我能够通过使用请求头中的X-CSRF-TOKEN
进行登录。但是在登录后,当我点击post请求时(我在请求头中包含了我用于登录post请求的相同令牌),我得到了以下错误消息:
CSRF状态403 -无法验证提供的令牌,因为找不到您的会话。
谁能指点我哪里做错了?
https://stackoverflow.com/questions/38004035
复制相似问题