我正在尝试了解 Spring (3.1) 中的身份验证提供程序,并且我对这里到底发生了什么有疑问。我知道我使用的命名空间可以更轻松地访问安全模块中的功能和配置。
当我有以下标签时,我会得到一个提供程序管理器,其中包含身份验证提供程序的列表。现在,当我查看 AuthenticationProvider 接口(interface)时,我想知道我得到了什么样的提供程序?我得到一个 DaoAuthenticationProvider
是对的吗?我是否可以获得其他提供商以及如何找到要注册的提供商(如果是这样做的话)?
<security:authentication-manager>
<security:authentication-provider>
<security:jdbc-user-service data-source-ref="dataSource" />
</security:authentication-provider>
</security:authentication-manager>
最佳答案
没错,您将得到 DaoAuthenticationProvider
与上面的配置。 documentation for <authentication-provider>
明确指出:
Unless used with a
ref
attribute, this element is shorthand for configuring aDaoAuthenticationProvider
.
<authentication-provider>
标签由 AuthenticationProviderBeanDefinitionParser
解析这总是 registers a DaoAuthenticationProvider
注入(inject)指定的 UserDetailsService
和其他合作者(passwordEncoder、saltSource 等)。
关于java - 了解 Spring security 中的身份验证提供程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16322458/