Last active
August 21, 2018 14:18
-
-
Save artem-smotrakov/f245889521b6ee786ae011f7a39b9ef4 to your computer and use it in GitHub Desktop.
An example of SecurityConfiguration for an application based on Spring framework
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
@Configuration | |
public class SecurityConfiguration extends WebSecurityConfigurerAdapter { | |
private static final String readScope = "#oauth2.isOAuth() && #oauth2.hasScope('read')"; | |
@Bean | |
@Override | |
public AuthenticationManager authenticationManagerBean() throws Exception { | |
return super.authenticationManagerBean(); | |
} | |
@Override | |
public void configure(final HttpSecurity http) throws Exception { | |
http.anonymous().disable(); | |
http.httpBasic().disable(); | |
http.logout().disable(); | |
http.loginForm().disable(); | |
http.headers().httpStrictTransportSecurity(); | |
http.authorizeRequests() | |
.antMatchers("/**").access(read) | |
.anyRequest().authenticated(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment