- 所有已实现的接口:
- org.springframework.security.config.annotation.SecurityConfigurer<javax.servlet.Filter,org.springframework.security.config.annotation.web.builders.WebSecurity>, org.springframework.security.config.annotation.web.WebSecurityConfigurer<org.springframework.security.config.annotation.web.builders.WebSecurity>
@EnableWebSecurity
public class VanasSecurityWebConfig
extends org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
类说明
通过@EnableWebSecurity注解开启Spring Security的功能
继承 WebSecurityConfigurerAdapter,并重写它的方法来设置一些web安全的细节
configure(HttpSecurity http)方法,
通过authorizeRequests()定义哪些URL需要被保护、哪些不需要被保护。
例如以上代码指定了/和/home不需要任何认证就可以访问,其他的路径都必须通过身份验证。
通过formLogin()定义当需要用户登录时候,转到的登录页面。
- 版本:
- v1.0 , Create at 10:13 PM 2020/3/4
- 作者:
- : alexliu