如何使用 SPNEGO 和 CAS 获取 LDAP 用户属性?

How to get LDAP user attributes with SPNEGO and CAS?

使用 CAS 5.3.x 和 SPNEGO (Kerberos) 身份验证,如何获得比 SAMAccountName 更多的用户属性?

当我只使用"standard" LDAP 身份验证处理程序时,我可以这样配置:

cas.authn.ldap[0].principalAttributeList=sAMAccountName,displayName,givenName,mail

但是在 SPNEGO 身份验证之后,我没有获得这些附加属性。

你知道怎么做吗?

自 3.x 以来,CAS 中就已经具备从外部数据存储中获取属性的功能。此功能过去和现在都由一个名为 Person Directory 的 Apereo 项目提供,该项目是一个 Java 框架,用于解析来自各种底层来源的人员和属性。它由一组组件组成,这些组件从 JDBC、LDAP 等检索、缓存、解析、聚合和合并人员属性。 CAS 试图通过一个名为 PrincipalResolver 的概念来利用此框架,其目标是为 CAS 构建一个最终可识别的经过身份验证的主体,其中包含从属性存储库源中获取的许多属性。这意味着,例如,可以在一个查询中使用 SPNEGO 进行身份验证,然后转向 ask LDAP、一个关系数据库和一个 Groovy 脚本来获取已解析主体的属性,并将所有结果合并到一个最终集合中。

请注意,在大多数情况下,例如直接 LDAP 身份验证,并从 CAS 4.x 开始,身份验证引擎已得到增强,能够从身份验证源检索和解析属性,这将消除了配置单独属性 repository/resolver 的需要,尤其是在身份验证和属性源相同的情况下。仅当来源不同或需要处理更高级的属性解析用例(例如级联、合并等)时才需要使用单独的解析器和来源。

要将 CAS 配置为将外部 LDAP 用于属性存储库,请使用:

cas.authn.attribute-repository.ldap[0].attributes.uid=uid
cas.authn.attribute-repository.ldap[0].attributes.displayName=displayName
cas.authn.attribute-repository.ldap[0].attributes.cn=commonName
cas.authn.attribute-repository.ldap[0].attributes.memberOf=memberOf

cas.authn.attribute-repository.ldap[0].ldapUrl=ldap://...
cas.authn.attribute-repository.ldap[0].useSsl=false
cas.authn.attribute-repository.ldap[0].useStartTls=false
cas.authn.attribute-repository.ldap[0].baseDn=dc=example,dc=edu
cas.authn.attribute-repository.ldap[0].searchFilter=uid={0}
cas.authn.attribute-repository.ldap[0].bindDn=...
cas.authn.attribute-repository.ldap[0].bindCredential=...