SecurityConfig.java 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package com.yihu.jw.config.security;
  2. import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
  3. import org.springframework.security.config.annotation.web.builders.HttpSecurity;
  4. import org.springframework.security.config.annotation.web.builders.WebSecurity;
  5. import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
  6. import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
  7. /**
  8. * Created by chenweida on 2017/11/29.
  9. */
  10. @EnableWebSecurity
  11. public class SecurityConfig extends WebSecurityConfigurerAdapter {
  12. /**
  13. * HttpSecurity:一般用它来具体控制权限,角色,url等安全的东西。
  14. * @param http
  15. * @throws Exception
  16. */
  17. @Override
  18. protected void configure(HttpSecurity http) throws Exception {
  19. http.authorizeRequests()
  20. .anyRequest()
  21. .fullyAuthenticated()
  22. .and()
  23. .httpBasic()
  24. .and()
  25. .csrf().disable();
  26. }
  27. /**
  28. * :用来做登录认证的
  29. * @param auth
  30. * @throws Exception
  31. */
  32. @Override
  33. protected void configure(AuthenticationManagerBuilder auth) throws Exception {
  34. super.configure(auth);
  35. }
  36. /**
  37. * For example, if you wish to ignore certain requests
  38. * @param web
  39. * @throws Exception
  40. */
  41. @Override
  42. public void configure(WebSecurity web) throws Exception {
  43. super.configure(web);
  44. }
  45. }