Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. @Configuration
  2. @EnableWebSecurity
  3. @EnableGlobalAuthentication
  4. public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
  5.  
  6. @Override
  7. protected void configure(HttpSecurity http) throws Exception {
  8. http.authorizeRequests()
  9. .antMatchers("/static/**")
  10. .permitAll()
  11. .anyRequest()
  12. .permitAll();
  13. http.formLogin()
  14. .loginPage("/")
  15. .permitAll()
  16. .and()
  17. .logout()
  18. .logoutSuccessUrl("/")
  19. .permitAll();
  20. http.authorizeRequests()
  21. .antMatchers("/**")
  22. .hasAnyRole("USER")
  23. .anyRequest()
  24. .authenticated();
  25. http.csrf()
  26. .disable();
  27. }
  28.  
  29. @Autowired
  30. public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
  31. auth.inMemoryAuthentication()
  32. .withUser("user")
  33. .password("user")
  34. .roles("USER");
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement