Untitled
unknown
java
2 years ago
1.1 kB
6
Indexable
@Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .antMatchers("/admin/**").hasRole(ROLE_ADMIN) .antMatchers("/client/**").hasRole(ROLE_CLIENT) .antMatchers("/expert/**").hasRole(ROLE_EXPERT) .and() .formLogin() .loginPage("/login") .permitAll() .and() .logout() .logoutSuccessUrl("/") .permitAll(); } @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.inMemoryAuthentication() .withUser("admin").password("password").roles(ROLE_ADMIN) .and() .withUser("client").password("password").roles(ROLE_CLIENT) .and() .withUser("expert").password("password").roles(ROLE_EXPERT); } }
Editor is loading...