Skip to content

Instantly share code, notes, and snippets.

@pedroveras
Created December 7, 2020 02:52
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 pedroveras/6c7e8e4313ca90b324701c51f24594c8 to your computer and use it in GitHub Desktop.
Save pedroveras/6c7e8e4313ca90b324701c51f24594c8 to your computer and use it in GitHub Desktop.
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests(authorizeRequests ->
authorizeRequests
.antMatchers(HttpMethod.GET, "/hello").hasAuthority("SCOPE_hello")
.anyRequest().authenticated()
).oauth2ResourceServer(OAuth2ResourceServerConfigurer::jwt);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment