我在 Spring Boot 中有三个应用程序,身份验证是通过 cas 服务器(azure 租户)完成的。如果用户登录这三个应用程序中的任何一个并尝试访问其他两个应用程序中的任何一个,我希望他们不必再次登录,而是被重定向到登录页面。当我将 cas 从 5.3.16 升级到 6.2.8 时,出现了这些问题。这曾经适用于旧版本。
服务从以下 json 文件加载到 cas:
egate-1001.json
not-1003.json
制裁-1004.json
我只会发布其中之一,因为它们具有相同的结构。
not-1003.json:
{
"@class": "org.apereo.cas.services.RegexRegisteredService",
"serviceId": "https://${ENV_EGATE_HOST}/not/.*",
"name": "Notifications",
"description": "eGate Notifications application",
"id": 1003,
"matchingStrategy": {
"@class": "org.apereo.cas.services.FullRegexRegisteredServiceMatchingStrategy"
},
"logoutType": "FRONT_CHANNEL",
"logoutUrl": "https://${ENV_EGATE_HOST}/not/j_spring_cas_security_logout",
"evaluationOrder": 10000003,
"attributeReleasePolicy": {
"@class": "org.apereo.cas.services.ReturnAllAttributeReleasePolicy"
}
}
这是 cas.properties 文件。
cas.server.name=https://${ENV_EGATE_HOST}
cas.server.prefix=${cas.server.name}/cas
server.port=8443
cas.service-registry.init-from-json=false
cas.service-registry.json.location=file:${ENV_CAS_CONFIGPATH}/services
cas.authn.pac4j.oidc[0].generic.type=AZURE
cas.authn.pac4j.oidc[0].generic.discoveryUri=https://login.microsoftonline.com/${ENV_AZURE_TENANTID}/v2.0/.well-known/openid-configuration
cas.authn.pac4j.oidc[0].generic.logoutUrl=https://login.microsoftonline.com/${ENV_AZURE_TENANTID}/oauth2/logout?post_logout_redirect_uri=https://${ENV_EGATE_HOST}/cas/
cas.authn.pac4j.oidc[0].generic.id=${ENV_AZURE_APPID}
cas.authn.pac4j.oidc[0].generic.secret=${ENV_AZURE_SECRET}
cas.authn.pac4j.oidc[0].generic.auto-redirect=false
cas.authn.pac4j.oidc[0].generic.clientName=${ENV_AZURE_APPNAME}
cas.authn.pac4j.oidc[0].generic.azureTenantId=${ENV_AZURE_TENANTID}
cas.authn.pac4j.oidc[0].generic.responseType=code
cas.authn.pac4j.oidc[0].generic.useNonce=true
cas.authn.pac4j.oidc[0].generic.scope=openid profile
cas.authn.pac4j.typedIdUsed=false
cas.view.cas2.v3ForwardCompatible=true
management.endpoints.enabled-by-default = true
management.endpoints.actuatorEndpointsEnabled = true
cas.monitor.endpoints.enabled = true
cas.monitor.endpoints.sensitive = false
cas.authn.pac4j.cookie.crypto.encryption.key=${ENV_CAS_COOKIE_ENCRYPRION_KEY}
cas.authn.pac4j.cookie.crypto.signing.key=${ENV_CAS_COOKIE_SIGNING_KEY}
cas.tgc.crypto.encryption.key=${ENV_CAS_TGC_ENCRYPTION_KEY}
cas.tgc.crypto.signing.key=${ENV_CAS_TGC_SIGNING_KEY}
cas.webflow.crypto.signing.key=${ENV_CAS_WEBFLOW_SIGNING_KEY}
cas.webflow.crypto.encryption.key=${ENV_CAS_WEBFLOW_ENCRYPTION_KEY}
每个应用程序都有一个 spring-security.xml 文件。它们是根据此文档编写的:https://docs.spring.io/spring-security/reference/servlet/authentication/cas.html
我尝试了 6 及以上版本的 cas 的不同版本,但没有成功。
有什么想法可能是什么问题吗?
提前致谢。
CAS 不记得您的 SSO 会话的问题似乎是由于 CAS 未正确返回带有 CAS SSO cookie 的
Set-Cookie
标头当使用委托身份验证(如本例中的 Azure)时,在某些情况下造成的情况。
这个问题(可能是一个错误)在 CAS 6.2.X:TGC Cookie 设置两次 进行了更彻底的讨论,并且在 仍在与 Azure AD 委托登录作斗争进行了更新鲜的讨论。
根据链接的论坛页面,迄今为止唯一可行的解决方法/解决方案是注释掉 Java 类
InitialFlowSetupAction中的行
ticketGrantingTicketCookieGenerator.removeCookie(response);
(即在 CAS 覆盖项目中覆盖此类)。