Spring Security 自动装配

2020-12-13 02:10

阅读:666

标签: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)属性  (AutowiredBeanFactoryObjectPostProcessor
  • 注册AutowiredWebSecurityConfigurersIgnoreParents,用于获取WebSecurityConfigurer类型Bean,并转化为List>格式
  • 使用objectObjectPostProcessor(AutowiredBeanFactoryObjectPostProcessor)创建webSecurity(WebSecurity)属性
  • 使用AutowiredWebSecurityConfigurersIgnoreParents获取List>并赋值给webSecurityConfigurers属性
  • 将webSecurityConfigurers中的WebSecurity值全部添加到webSecurity属性中
  • 注册DelegatingApplicationListener
  • 注册springSecurityFilterChain(Filter),创建DefaultSecurityFilterChain,加载默认的15个过滤器,创建FilterChainProxy,代理过滤器链
  • 注册SecurityExpressionHandler
  • 注册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


评论


亲,登录后才可以留言!