-
-
Save murraco/2e3c634329e689065b3c9158c6d0681c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Disable CSRF (cross site request forgery) | |
http.csrf().disable(); | |
// No session will be created or used by spring security | |
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); | |
// Entry points | |
http.authorizeRequests()// | |
.antMatchers("/users/signin").permitAll()// | |
.antMatchers("/users/signup").permitAll()// | |
// Disallow everything else.. | |
.anyRequest().authenticated(); | |
// If a user try to access a resource without having enough permissions | |
http.exceptionHandling().accessDeniedPage("/login"); | |
// Apply JWT | |
http.apply(new JwtTokenFilterConfigurer(jwtTokenProvider)); | |
// Optional, if you want to test the API from a browser | |
// http.httpBasic(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment