Skip to content

Instantly share code, notes, and snippets.

@khamiltonuk
Created November 29, 2015 22:42
Show Gist options
  • Select an option

  • Save khamiltonuk/3f7391ff475aadafae53 to your computer and use it in GitHub Desktop.

Select an option

Save khamiltonuk/3f7391ff475aadafae53 to your computer and use it in GitHub Desktop.
Simple CSRF Protection with Spring MVC
@Configuration
public class SellerWebsiteInterceptorsConfig
extends WebMvcConfigurerAdapter {
@Autowired
private SecureTokenService secureTokenService;
@Override
public void addInterceptors(InterceptorRegistry registry) {
// Put your other interceptors here too ….
registry.addInterceptor(secureTokenInterceptor());
}
@Bean
public HandlerInterceptor secureTokenInterceptor() {
return new SecureTokenInterceptor(secureTokenService);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment