SpringSecurity源码
再SpringBoot里面对SpringSecurity做了很好的集成
spring.factories
1 | org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration,\ |
SecurityAutoConfiguration
1 | false) (proxyBeanMethods = |
SecurityProperties
配置类
1 |
|
SpringBootWebSecurityConfiguration
配置类
1 |
|
WebSecurityEnablerConfiguration
1 | If there is a bean of type WebSecurityConfigurerAdapter, this adds the {@link EnableWebSecurity @EnableWebSecurity} annotation. This will make sure that the annotation is present with default security auto-configuration and also if the user adds custom security and forgets to add the annotation. If {@link EnableWebSecurity @EnableWebSecurity} has already been added or if a bean with name {@value BeanIds#SPRING_SECURITY_FILTER_CHAIN} has been configured by the user, this will back-off. |
SecurityDataConfiguration
1 |
|
SpringSecurity-config
@EnableWebSecurity
1 | /* |
@EnableGlobalAuthentication
1 | (value = java.lang.annotation.RetentionPolicy.RUNTIME) |
AuthenticationConfiguration
1 |
|
ObjectPostProcessorConfiguration
1 | false) (proxyBeanMethods = |
WebSecurityConfiguration
1 | public class WebSecurityConfiguration implements ImportAware, BeanClassLoaderAware { |
SpringWebMvcImportSelector
1 |
|
OAuth2ImportSelector
1 | final class OAuth2ImportSelector implements ImportSelector { |
UserDetailsServiceAutoConfiguration
1 | false) (proxyBeanMethods = |
SecurityFilterAutoConfiguration
1 | false) (proxyBeanMethods = |
流程
找到RegistrationBean的子类
1 |
|
找到filter
1 |
|
发现是通过webSecurity构建得到
1 |
|
又发现webSecurity获取是通过objectPostProcessor
1 | false) (required = |
看一下AutowireBeanFactoryObjectPostProcessor
1 |
|
WebSecurity构建
1 | public final class WebSecurity extends |
performBuild
1 | protected Filter performBuild() throws Exception { |
会发现使用了一层代理FilterChainProxy
1 |
|
HttpSecurity构建
1 |
|
- 本文作者: 忘忧症
- 本文链接: https://NepenthesZGW.github.io/2020/09/04/framework/SpringSecurity/SpringSecurity源码/
- 版权声明: 本博客所有文章除特别声明外,均采用 MIT 许可协议。转载请注明出处!