【发布时间】:2013-12-09 19:59:13
【问题描述】:
我正在尝试在我们的 Web 应用程序中实现预认证的安全性,但我不确定如何正确执行。外面没有那么多例子。而那些似乎比我们的设置简单得多。
我们在请求标头中以 XML 形式获取身份验证详细信息,其中包含名字、姓氏、用户 ID 和错误标记(如果发生)。
我正在扩展 AbstractPreAuthenticatedProcessingFilter 并在其 getPreAuthenticatedPrincipal() 中提取标题,解组它并进行一些验证。
现在问题:
- 如果一切正常,我是否只需从
getPreAuthenticatedPrincipal()退回我未编组的 shibboleth? - 如果有什么问题,我是不是直接扔了
PreAuthenticatedCredentialsNotFoundException? - 我从
getPreAuthenticatedCredentials()返回什么?"N/A"够用吗?
我想在某些时候我还没有创建 Authentication 和 Principal。
-
这是一个好方法吗?
Principal dynamicUser = new DynamicUser(rijksregisterNummer); List<SimpleGrantedAuthority> grantedAuthorities = Arrays.asList(new SimpleGrantedAuthority("ROLE_USER")); Authentication authentication = new AnonymousAuthenticationToken(rijksregisterNummer, dynamicUser, grantedAuthorities); 我应该在什么时候(在哪个类中)在 Spring Security 中设置它?
我还需要扩展哪些其他类?
-
如何配置 Spring Security 配置 XML?像这样?我错过了什么?
<http> <custom-filter position="PRE_AUTH_FILTER" ref="myPreAuthFilter" /> </http> <bean id="myPreAuthFilter" class="my.package.MyPreAuthenticationFilter"> <property name="authenticationManager" ref="authenticationManager"/> </bean> <authentication-manager alias="authenticationManager"> <authentication-provider ref="customAuthenticationProvider"/> </authentication-manager>
外部用户通过预身份验证(使用电子身份证和读卡器),然后点击我们的网络应用程序。然而,内部用户必须使用用户名和密码进行身份验证,这是一个正常的身份验证过程。
- 如何设置在没有 shibboleth(因此我们的内部用户登录)时,我可以显示登录表单?
很多问题,我知道。我希望你能指导我。
【问题讨论】:
-
尝试按照本教程进行操作。这个非常好。 krams915.blogspot.in/2010/12/…
-
信息丰富,但不幸的是它没有解释如何使用 pre- 身份验证过滤器。
-
你读过the ref manual吗? pre-auth sample app 和各种 out of the box implementations 的组合应该可以满足您的大部分需求。
标签: java spring web-applications spring-security