Skip to content

Instantly share code, notes, and snippets.

@dvas0004
Last active March 2, 2018 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvas0004/9d8308bc61953dd257c74f43bb4ba592 to your computer and use it in GitHub Desktop.
Save dvas0004/9d8308bc61953dd257c74f43bb4ba592 to your computer and use it in GitHub Desktop.
@EnableWebSecurity
public class SecurityConfig {
@Value("${security.enabled:false}")
private Boolean security_enabled;
@Configuration
@Order(1)
public class BasicSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.antMatcher("/googleToken").authorizeRequests().anyRequest().permitAll();
http.csrf().disable();
}
}
@Configuration
@Order(2)
public class JwtSecurityConfig extends WebSecurityConfigurerAdapter {
@Value("${jwtSecret}")
private String jwtSecret;
@Override
protected void configure(HttpSecurity http) throws Exception {
http.addFilterAfter(new JWTFilter(jwtSecret), BasicAuthenticationFilter.class);
http.authorizeRequests()
.antMatchers("/actuator/*").hasAuthority("ACTUATOR")
.antMatchers("/**").permitAll();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment