Skip to content

Instantly share code, notes, and snippets.

@sjyun
Created August 19, 2018 01:34
Show Gist options
  • Save sjyun/2d6213d2461856c5149f4c38440a03ee to your computer and use it in GitHub Desktop.
Save sjyun/2d6213d2461856c5149f4c38440a03ee to your computer and use it in GitHub Desktop.
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override protected void configure(HttpSecurity http) throws Exception {
http.httpBasic().and()
.authorizeRequests()
.requestMatchers(EndpointRequest.to("info", "health")).permitAll()
.requestMatchers(EndpointRequest.toAnyEndpoint()).hasRole("SYSTEM")
.antMatchers("/**").hasRole("USER"); }
@Override protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.passwordEncoder(new MessageDigestPasswordEncoder("SHA-256"))
.withUser("user")
.password("5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8")
.roles("USER") .and() .withUser("sysuser") .password("5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8")
.roles("SYSTEM");
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment