是的,CAS 可以针对多个来源进行身份验证。在您的authenticationManager
bean 中,您应该有一个名为authenticationHandlers
;的属性。在那里,定义多个AuthenticationHandler
bean。对于我的设置,我有一个本地文件(用于从 Munin/Nagios 监视用户)身份验证处理程序和一个BindLdapAuthenticationHandler
:
<property name="authenticationHandlers">
<list>
<!-- This is the authentication handler that authenticates
services by means of callback via SSL, thereby validating
a server side SSL certificate. -->
<bean class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler" p:httpClient-ref="httpClient" />
<bean class="org.jasig.cas.adaptors.generic.FileAuthenticationHandler" p:fileName="${cas.localuser.file}" />
<bean class="org.jasig.cas.adaptors.ldap.BindLdapAuthenticationHandler"
p:timeout="10000"
p:filter="${ldap.auth.filter}"
p:searchBase="${ldap.base.dn}"
p:ignorePartialResultException="true"
p:contextSource-ref="contextSource"
p:searchContextSource-ref="searchContextSource"
/>
</list>
</property>
只需为要对其进行身份验证的其他事物添加更多身份验证处理程序。查看CAS LDAP 处理程序的https://wiki.jasig.org/display/CASUM/LDAP和 CAS Active Directory 处理程序的https://wiki.jasig.org/display/CASUM/Active+Directory 。
它的工作方式是,CAS 将尝试按顺序对每个处理程序进行身份验证。第一个成功的结果是成功的 CAS 登录。因此,如果您在 LDAP 中有一条 uid=jsmith 的记录,而在 AD 中有一条 cn=jsmith 的记录,并且它们都具有相同的密码,那么无论哪个在 CAS 中首先定义,都将永远获胜!因此,您应该确保您的系统之间没有登录 ID 冲突,否则您可能会面临一些不良副作用(特别是如果 LDAP 中的 jsmith 与 AD 中的 jsmith 不是同一个人)。
如果您使用 SAML 验证(例如 for mod_auth_cas
),您可能还有其他注意事项。您可以定义一个attributeRepository
bean,该 bean 列出了在人员进行身份验证并且服务使用/samlValidate
. 我不知道是否有可用的 bean 类可以让您从多个目录中提取,但如果您不使用samlValidate
它,无论如何这对您来说可能不是问题。
那么有没有更好的方法呢?好吧,如果可能的话,请归结为一种身份验证事实来源。
关于 CAS 联盟:没有。您可能能够设置服务器,以便它们信任彼此的票证,但我建议使用一个 CAS 环境(如果您愿意,可以将其集群化)对尽可能少的身份验证源进行身份验证。