我无法发现我需要实现的内容,以便使用Spring Security的Web应用程序使用自定义身份验证方法.我有一个带有Spring Security插件的Grails应用程序,该插件目前使用标准用户/密码身份验证和浏览器表单.这是正常的.
我需要实现一种机制,实现一种MAC身份验证.如果HTTP请求包含多个参数(例如用户标识符,时间戳,签名等),我需要获取这些参数,执行一些散列和签名/时间戳比较,然后对用户进行身份验证.
我不是100%确定从哪里开始.我需要扩展/实现哪些Spring Security类?我已阅读参考文档并对概念有一个正确的理解,但我不确定我是否需要过滤器或提供程序或管理器,或者在何处/如何准确创建身份验证对象.我试图扩展AbstractProcessingFilter和/或实现AuthenticationProvider,但我只是理解了如何让它们完美地发挥作用.
lsi*_*siu 23
实现自定义的AuthenticationProvider,其会从所有身份验证信息Authentication:getCredentials(),getDetails(),和getPrincipal().
使用以下配置代码段将其绑定到Spring Security身份验证机制中:
<bean id="myAuthenticationProvider" class="com.example.MyAuthenticationProvider">
<security:custom-authentication-provider />
</bean>
Run Code Online (Sandbox Code Playgroud)
如果您可以从标准实现中找到合适的步骤,则此步骤是可选的.如果没有,请实现一个扩展Authentication接口的类,您可以在其上放置您的身份验证参数:
(e.g. a user identifier, timestamp, signature, etc.)
Run Code Online (Sandbox Code Playgroud)扩展SpringSecurityFilter将上述两个类绑定在一起的自定义.例如,Filter可能会使用您的实现输入来AuthenticationManager调用和调用.authenticate()Authentication
您可以将AbstractAuthenticationProcessingFilter扩展为开头.
您可以引用扩展的UsernamePasswordAuthenticationFilterAbstractAuthenticationProcessingFilter.UsernamePasswordAuthenticationFilter实现标准用户名/密码验证.
配置Spring Security以添加或替换标准AUTHENTICATION_PROCESSING_FILTER.有关Spring Security Filter订单的信息,请参阅http://static.springsource.org/spring-security/site/docs/3.0.x/reference/ns-config.html#filter-stack
以下是如何使用您的实现替换它的配置代码段:
<beans:bean id="myFilter" class="com.example.MyAuthenticationFilter">
<custom-filter position="AUTHENTICATION_PROCESSING_FILTER"/>
</beans:bean>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
24690 次 |
| 最近记录: |