Java - Spring - Security (HttpSecurity - Cross Site Request Forgery CSRF)

Java - Spring - Security (HttpSecurity - Cross Site Request Forgery CSRF)

Protecting against Cross-Site Request Forging (CSRF)

1 - Configure CSRF Protection

@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

	@Override
	protected void configure(HttpSecurity http) throws Exception {
		http
			.csrf().disable();
	}
}

2 - Include the CSRF Token

see: https://docs.spring.io/spring-security/site/docs/5.0.x/reference/html/csrf.html#csrf-include-csrf-token

3 - Other