Jaz*_*epi 8 spring-security spring-boot
WebSecurityConfigurerAdapter 提供两种覆盖,如下所示:
protected void configure(AuthenticationManagerBuilder auth)
和
protected void configure(HttpSecurity http)
两者HttpSecurity都AuthenticationManagerBuilder提供身份验证提供商的注册。注册我的提供商与另一提供商之间有什么区别吗?
我还使用 Spring boot 2.1 来@SpringBootApplication(exclude = SecurityAutoConfiguration.class)完全关闭它们的自动配置。
\n\n\n\n\n身份验证的主要策略接口是\n
\n\nAuthenticationManager[...]最常用的实现
\n\nAuthenticationManager是\nProviderManager,它委托给\n 实例链AuthenticationProvider。AnAuthenticationProvider有点像AuthenticationManager[...]A
\n\nProviderManager可以通过委托链来支持同一应用程序中的多种不同的身份验证机制AuthenticationProviders。如果 aProviderManager无法识别特定Authentication实例类型,则它将被跳过。A
\nProviderManager有一个可选的父级,如果所有提供者都返回 null,则 A 可以咨询该父级。如果父级不可用,则 null\nAuthentication会导致AuthenticationException.
一般来说,除了WebSecurityConfigurerAdapter提供配置(如等)之外,它还通过使用创建和配置(添加和父级)。HttpSecurityFilterUsernamePasswordAuthenticationFilterLogoutFilterAuthenticationProviderAuthenticationManagerAuthenticationManagerHttpSecurityAuthenticationManagerBuilder
WebSecurityConfigurerAdapterAuthenticationManager将为只创建一个HttpSecurity。然而AuthenticationManager有它自己的AuthenticationProviders和它自己的可选的parent AuthenticationProvider。当你这样做时,http.authenticationProvider(...)你正在向属于那个的添加 AuthenticationProvider新AuthenticationManager的http。通过使用,configure(AuthenticationManagerBuilder auth)您可以配置哪个是属于该特定 的AuthenticationManager父级。AuthenticationManagerHttpSecurity
Spring 为该特定的父级提供默认配置AuthenticationManager,但是通过使用configure(AuthenticationManagerBuilder auth)您将拒绝 spring 的配置以支持您的(auth)。
| 归档时间: |
|
| 查看次数: |
1501 次 |
| 最近记录: |