背景
在 #444 的 review 中,我们决定不合并基于私有协议的 SSO 实现,转而支持标准 CAS 2.0/3.0 协议,使 OSS 用户可以对接 Apereo CAS Server、Keycloak CAS adapter 等主流实现。
关联 PR:#444(已关闭)
目标
实现标准 CAS 2.0/3.0 协议的 SSO 登录集成,复用现有 IdentityBindingService 身份映射抽象。
设计要点
协议支持
- CAS 2.0:
GET /serviceValidate?ticket=...&service=... → XML 响应
- CAS 3.0:
GET /p3/serviceValidate?ticket=...&service=...&format=JSON → JSON 响应
- 优先实现 3.0 JSON 模式,兼容 2.0 XML fallback
架构原则
- 复用
IdentityBindingService:将 CAS attributes 适配为通用 IdentityClaims(需先将 IdentityBindingService.bindOrCreate 的入参从 OAuthClaims 抽象为 provider-neutral 接口)
- 复用
OAuthLoginRedirectSupport.sanitizeReturnTo():防止 open redirect
- HTTPS 强校验:
@PostConstruct 校验 CAS server URL 必须为 HTTPS(或提供显式 escape hatch 用于开发环境)
- Feature flag:默认 disabled,通过
skillhub.auth.cas.enabled=true 启用
配置项(初步)
skillhub:
auth:
cas:
enabled: false
server-url: https://cas.example.com # CAS server base URL
service-url: https://skillhub.example.com/api/v1/auth/cas/callback
protocol-version: 3.0 # 2.0 | 3.0
attributes:
username: uid # CAS attribute → platform username
display-name: cn # CAS attribute → display name
email: mail # CAS attribute → email (optional)
前端
实现步骤
参考
备注
- 如果内部部署需要对接非标准 CAS 协议(如讯飞内部 SSO 网关),建议作为独立私有模块维护,不进 OSS 主干
- 可考虑直接使用
spring-security-cas 模块,但需评估与现有 PlatformSessionService 的集成成本
背景
在 #444 的 review 中,我们决定不合并基于私有协议的 SSO 实现,转而支持标准 CAS 2.0/3.0 协议,使 OSS 用户可以对接 Apereo CAS Server、Keycloak CAS adapter 等主流实现。
关联 PR:#444(已关闭)
目标
实现标准 CAS 2.0/3.0 协议的 SSO 登录集成,复用现有
IdentityBindingService身份映射抽象。设计要点
协议支持
GET /serviceValidate?ticket=...&service=...→ XML 响应GET /p3/serviceValidate?ticket=...&service=...&format=JSON→ JSON 响应架构原则
IdentityBindingService:将 CAS attributes 适配为通用IdentityClaims(需先将IdentityBindingService.bindOrCreate的入参从OAuthClaims抽象为 provider-neutral 接口)OAuthLoginRedirectSupport.sanitizeReturnTo():防止 open redirect@PostConstruct校验 CAS server URL 必须为 HTTPS(或提供显式 escape hatch 用于开发环境)skillhub.auth.cas.enabled=true启用配置项(初步)
前端
authCasEnabled控制显隐SsoLoginEntry的 UI 模式实现步骤
IdentityBindingService.bindOrCreate(OAuthClaims)抽象为IdentityClaims接口,OAuth 和 CAS 各自实现CasProperties配置类 +@PostConstruct校验CasTicketValidator(GET serviceValidate,解析 XML/JSON)CasLoginController(/login 重定向 + /callback 票据验证)CasIdentityClaims适配器,调用IdentityBindingServiceRouteSecurityPolicyRegistry放行/api/v1/auth/cas/**CasLoginEntry组件 + runtime config30-runtime-config.sh添加SKILLHUB_WEB_AUTH_CAS_ENABLED参考
备注
spring-security-cas模块,但需评估与现有PlatformSessionService的集成成本