Created
August 19, 2018 01:34
-
-
Save sjyun/2d6213d2461856c5149f4c38440a03ee to your computer and use it in GitHub Desktop.
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 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