码迷,mamicode.com
首页 > 编程语言 > 详细

Spring Security 自动装配

时间:2019-06-15 13:38:33      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:enable   lsb   导入   ati   autoconf   load   col   list   bug   

1、自动装配的配置类

org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration         // 自动装配类
  • 注册DefaultAuthenticationEventPublisher
org.springframework.boot.autoconfigure.security.SecurityProperties                  // properties对应的属性配置类
org.springframework.boot.autoconfigure.security.servlet.SpringBootWebSecurityConfiguration    // 注入配置类,用于装载Spring Security个性化配置(WebSecurityConfigurerAdapter: DefaultConfigurerAdapter
org.springframework.boot.autoconfigure.security.servlet.WebSecurityEnablerConfiguration       // 开启@EnableWebSecurity手动装配
@EnableWebSecurity
  WebSecurityConfiguration:
  • 实现ImportAware, BeanClassLoaderAware接口,加载debugEnabled(boolean),beanClassLoader(ClassLoader)属性
  • 注入objectObjectPostProcessor(ObjectPostProcessor<Object>)属性  (AutowiredBeanFactoryObjectPostProcessor
  • 注册AutowiredWebSecurityConfigurersIgnoreParents,用于获取WebSecurityConfigurer类型Bean,并转化为List<WebSecurityConfigurer<Filter, WebSecurity>>格式
  • 使用objectObjectPostProcessor(AutowiredBeanFactoryObjectPostProcessor)创建webSecurity(WebSecurity)属性
  • 使用AutowiredWebSecurityConfigurersIgnoreParents获取List<WebSecurityConfigurer<Filter, WebSecurity>>并赋值给webSecurityConfigurers属性
  • 将webSecurityConfigurers中的WebSecurity值全部添加到webSecurity属性中
  • 注册DelegatingApplicationListener
  • 注册springSecurityFilterChain(Filter),创建DefaultSecurityFilterChain,加载默认的15个过滤器,创建FilterChainProxy,代理过滤器链
  • 注册SecurityExpressionHandler<FilterInvocation>
  • 注册WebInvocationPrivilegeEvaluator(DefaultWebInvocationPrivilegeEvaluator)

  SpringWebMvcImportSelector:

  • 选择注册WebMvcSecurityConfiguration

  OAuth2ImportSelector:

  • 选择注册OAuth2ClientConfiguration

  @EnableGlobalAuthentication

    AuthenticationConfiguration

    • 导入ObjectPostProcessorConfiguration,注册AutowiredBeanFactoryObjectPostProcessor
    • 注册AuthenticationManagerBuilder,EnableGlobalAuthenticationAutowiredConfigurer,InitializeUserDetailsBeanManagerConfigurer,InitializeAuthenticationProviderBeanManagerConfigurer

 

Spring Security 自动装配

标签:enable   lsb   导入   ati   autoconf   load   col   list   bug   

原文地址:https://www.cnblogs.com/pascall/p/11027072.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!