Skip to content

Instantly share code, notes, and snippets.

@Phoenix124
Created February 28, 2019 09:34
Show Gist options
  • Save Phoenix124/4aef2832b91ecb556564ad4e202486c9 to your computer and use it in GitHub Desktop.
Save Phoenix124/4aef2832b91ecb556564ad4e202486c9 to your computer and use it in GitHub Desktop.
@Configuration
@Order(1)
public static class BasicAuthenticationAdapter extends WebSecurityConfigurerAdapter {
private final AuthenticationEntryPoint authEntryPoint;
@Autowired
public BasicAuthenticationAdapter(AuthenticationEntryPoint authEntryPoint) {
this.authEntryPoint = authEntryPoint;
}
protected void configure(HttpSecurity http) throws Exception {
http
.antMatcher("/orders**")
.authorizeRequests()
.anyRequest().hasRole("USER")
.and()
.csrf().disable()
.httpBasic().authenticationEntryPoint(authEntryPoint)
.and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment