且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

单点登录(SSO):如何使用Active Directory作为CAS服务的身份验证方法?

更新时间:2023-12-04 23:08:16

我在这里做了一些假设,所以请让我知道,如果我要去的目标:

I'm making a few assumptions here, so please let me know if I'm off target:

  1. 您使用的是3.3.2和3.4.8之间的版本中国科学院。
  2. 您想通过LDAP配合CAS到Active Directory(对于Kerberos或SPNEGO见下文参考)使用LDAP绑定处理程序(用于快速绑定见下文参考资料)。
  3. 您已经熟悉了通过Maven的从源代码构建CAS。
  • 如果你打算通过LDAPS://绑定到AD(相对于LDAP://),在JVM的CAS服务器上需要信任Active Directory服务器的SSL证书。如果您使用的是自签名证书的广告,您需要导入该到JVM的信任存储区。

在你的CAS源代码树,你需要更改下列文件:

Within your CAS source tree, you'll need to make changes to the following files:

  • CAS-服务器的webapp / pom.xml的
  • CAS-服务器的webapp / src目录/主/ web应用/ WEB-INF / deployerConfigContext.xml里

的pom.xml:

添加以下在<依赖>

<!-- LDAP support -->
<dependency>
    <groupId>${project.groupId}</groupId>
    <artifactId>cas-server-support-ldap</artifactId>
    <version>${project.version}</version>
</dependency>

deployerConfigContext.xml里:

  1. 重新配置认证左撇子:

  1. Reconfigure your Authentication Handers:

  • 查找:&LT;属性名=authenticationHandlers&GT; 。这里面是一个&LT;列表&gt; 了,里面这是(可能)两个&LT;豆...&GT; 元素
  • 请这一个:

  • Look for: <property name="authenticationHandlers">. Inside this is a <list>, and inside this are (probably) two <bean ...> elements
  • Keep this one:

<bean class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler" p:httpClient-ref="httpClient" />

  • 其他&LT;豆&GT; (同​​样,可能)对应于身份验证您正在使用当前的方法。 (我不清楚依据的问题,因为有几个方法 CAS可以做到这一点,而无需使用外部服务。默认值是SimpleTestUsernamePasswordAut​​henticationHandler,这个认证,只要用户名相同的密码)。替换&LT;豆&GT;

  • The other <bean> (again, probably) corresponds to the current method of authentication you're using. (I'm not clear based upon the question, as there are several ways CAS can do this without using external services. The default is SimpleTestUsernamePasswordAuthenticationHandler, this authenticates as long as username is equal to password). Replace that <bean> with:

    <!-- LDAP bind Authentication Handler -->
    <bean class="org.jasig.cas.adaptors.ldap.BindLdapAuthenticationHandler">
    <property name="filter" value="uid=%u" />
        <property name="searchBase" value="{your LDAP search path, e.g.: cn=users,dc=example,dc=com}" />
        <property name="contextSource" ref="LDAPcontextSource" />
        <property name="ignorePartialResultException" value="yes" /> <!-- fix because of how AD returns results -->
    </bean>
    

  • 根据您的广告配置修改searchBase属性。

  • Modify the "searchBase" property according to your AD configuration.

    创建上下文来源为LDAP:

    Create a Context Source for LDAP:

    • 添加这个地方的根目录中&LT;豆类&GT; 元素:

    <bean id="LDAPcontextSource" class="org.springframework.ldap.core.support.LdapContextSource">
        <property name="pooled" value="false"/>
        <property name="urls">
            <list>
                <value>{URL of your AD server, e.g.: ldaps://ad.example.com}/</value>
            </list>
        </property>
        <property name="userDn" value="{your account that has permission to bind to AD, e.g.: uid=someuser, dc=example, dc=com}"/>
        <property name="password" value="{your password for bind}"/>
        <property name="baseEnvironmentProperties">
            <map>
                <entry>
                    <key>
                        <value>java.naming.security.authentication</value>
                    </key>
                    <value>simple</value>
                </entry>
            </map>
        </property>
    </bean>
    

  • 修改网址,用户DN和密码相应。

  • Modify "urls", "userDn" and "password" accordingly.

    重建CAS服务器,Web应用和尝试。

    Rebuild cas-server-webapp and try it.

    • https://wiki.jasig.org/display/CASUM/LDAP
    • https://wiki.jasig.org/display/CASUM/Active+Directory