/WebSecurityConfig.java Secret
Created
November 11, 2017 16:48
Star
You must be signed in to star a gist
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