我在尝试使用 Spring Security 使用现有(阅读:非常“传统”)单点登录解决方案来保护新的 Spring MVC 应用程序时遇到了一些问题。
免责声明:我对 Spring 整体比较熟悉,但对 Spring Security 完全不熟悉;请原谅我的无知。
SSO 服务的工作方式如下:
- 用户导航到他们选择的 Web 应用程序:http: //apps.myco.com/webapp123
- 用户未通过身份验证,因此他们被重定向到http://sso.myco.com/login并提示登录
- 用户通过身份验证并使用附加到查询字符串的令牌重定向回应用程序:http ://apps.myco.com/webapp123?token=ABCD1234
- 在每次页面加载(当前为 JSP 页面)时,用户的令牌会从查询字符串中提取出来,然后通过 SOAP 回调触发 SSO 服务,以检查令牌的有效性。SSO 服务对令牌表示赞成或反对(如果令牌有效且仍然是最新的,则表示赞成;否则,表示反对)
- 如果令牌有效,则可以进行另一个 SOAP 调用以获取用户名(如果需要)
SSO 服务不处理用于授权的用户凭据,因此必须在每个应用程序的基础上进行处理:(
据我了解,这里普遍接受的做法是使用 Spring Security 的预身份验证框架,但我 (a) 不确定我的假设是否正确,并且 (b) 不确定我需要附带的所有东西该解决方案。
目前,我LoginUrlAuthenticationEntryPoint
定义了一个 bean,它将未经身份验证的用户定向到 SSO 站点:
<beans:bean id="customAuthenticationEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
<beans:constructor-arg value="http://sso.myco.com/login" />
</beans:bean>
入口点的连接方式如下:
<http use-expressions="true" entry-point-ref="customAuthenticationEntryPoint">
<intercept-url pattern="/" access="permitAll" />
<intercept-url pattern="/edit/**" access="isAuthenticated()" />
<intercept-url pattern="/setup/**" access="hasRole('setup')" />
<intercept-url pattern="/admin/**" access="hasRole('admin')" />
</http>
对我来说,症结在于在哪里挂接以接收来自 SSO 服务的“回调”。我想要的是有一个 URL(比如http://apps.myco.com/webapp123/auth?token=ABCD1234)接受来自 SSO 服务的这些重定向,验证令牌并从 SSO 检索用户名,然后将所有这些信息保存在 Spring Security 上下文中。然而,我很有可能走错了路,或者我只是错过了一两块。
非常感谢任何帮助或指导。