Skip to content

Instantly share code, notes, and snippets.

@aSemy
Last active May 30, 2018 14:38
Show Gist options
  • Save aSemy/a6d9806b483152ed540dccf508560130 to your computer and use it in GitHub Desktop.
Save aSemy/a6d9806b483152ed540dccf508560130 to your computer and use it in GitHub Desktop.
CookieCsrfTokenRepository
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
final CsrfTokenRepository csrfTokenRepository = CookieCsrfTokenRepository.withHttpOnlyFalse();
http
.cors()
.and()
// enable CSRF
.csrf().csrfTokenRepository(csrfTokenRepository)
// ...
;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment