Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Configuration
- @EnableWebSecurity
- @EnableGlobalAuthentication
- public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- http.authorizeRequests()
- .antMatchers("/static/**")
- .permitAll()
- .anyRequest()
- .permitAll();
- http.formLogin()
- .loginPage("/")
- .permitAll()
- .and()
- .logout()
- .logoutSuccessUrl("/")
- .permitAll();
- http.authorizeRequests()
- .antMatchers("/**")
- .hasAnyRole("USER")
- .anyRequest()
- .authenticated();
- http.csrf()
- .disable();
- }
- @Autowired
- public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
- auth.inMemoryAuthentication()
- .withUser("user")
- .password("user")
- .roles("USER");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement