我有一个连接CAS服务器的应用程序,允许用户进行CAS / SSO登录,然后将它们重定向到应用程序的主页。很简单。
问题是CAS对我的组织来说相对较新,截至今天,我们只在一台服务器上设置CAS。因此,如果服务器因任何原因无法访问,则无法再访问该应用程序,因为CAS登录页面将无法加载。
我希望我的应用程序能够检测到 a)经过合理的重试次数后,CAS服务器无法访问 b)随后将用户重定向到非CAS / SSO登录页面并使用使用LDAP的基本Spring Security配置
我在这个特定场景的Spring文档中没有看到任何内容。建议?
答案 0 :(得分:0)
您可以尝试扩展CasAuthenticationEntryPoint
。 Spring Security中的入口点决定了在需要身份验证时的去向。
public LocalLoginFallbackCasAuthenticationEntryPoint
extends CasAuthenticationEntryPoint {
@Override
protected String createRedirectUrl(final String serviceUrl) {
if ( prevailingCircumstancesMandate() ) {
return "/our/legacy/login/page";
} else {
// go to CAS, like normal
return super.createRedirectUrl(serviceUrl);
}
}
}
然后在HttpSecurity
对象中进行配置:
@Override
protected void configure(HttpSecurity http) {
http.exceptionHandling()
.authenticationEntryPoint(myCustomEntryPoint());
}