3、用CAS接口对接

1.修改CAS对接参数

[root@www ~]# vi /opt/shibboleth-idp/conf/idp.properties
#修改
idp.authn.flows = External

#新增
shibcas.casServerUrlPrefix = https://xxx.xxx.xxx.xxx/cas
#CAS服务器域名
shibcas.casServerLoginUrl = ${shibcas.casServerUrlPrefix}/login
shibcas.serverName = https://xxx.xxx.xxx.xxx
#IdP的域名  

# cas 的协议,如不配置则默认取 cas3.0 如果 cas 只支持 2.0 则取消该条注释修改为 cas20
# shibcas.ticketValidatorName = cas30

2.配置属性定义

        eduPersonScopedAffiliation属性,取值为用户在学校的身份,其中的“userType”为CAS中确定用户身份的属性名称,请替换成实际使用的属性名。关于身份属性取值,需要将CAS用户身份的取值,对应到CARSI联盟标准取值,包括:faculty(教师),student(学生),staff(教工),employee(雇员),member(各类人员,包括faculty、student、staff、employee),alum(校友),affiliate(附属人员或临聘,常用),other(CARSI补充,不建议优先使用)。下文样例,将所有的本地用户区分为“staff”、“student”、“member”三种身份。学校可根据本地LDAP实际部署情况选取其中的一部分值。不同SP对用户身份的要求不同,建议配置时尽可能细化用户身份分类,避免后期修改配置。

       注:只需要修改下述eduPersonScopedAffiliation属性定义即可,其他内容不需要修改

[root@www ~]# sudo vi /opt/shibboleth-idp/conf/attribute-resolver.xml
    <AttributeDefinition xsi:type="ScriptedAttribute" id="eduPersonScopedAffiliation">
        <InputAttributeDefinition ref="usertype" />
        <Script><![CDATA[
        var localpart = "";
        if(typeof(usertype)=="undefined"){
            localpart = "member";
        }else{
            if(usertype.getValues().get(0)=="staf") localpart = "staff";
            else if(usertype.getValues().get(0)=="std") localpart = "student";
            else localpart = "member";
        }
        eduPersonScopedAffiliation.addValue(localpart + "@%{idp.scope}");
            ]]></Script>
        <AttributeEncoder xsi:type="SAML1String" name="urn:mace:dir:attribute-def:eduPersonScopedAffiliation" encodeType="false" />
        <AttributeEncoder xsi:type="SAML2String" name="urn:oid:1.3.6.1.4.1.5923.1.1.1.9" friendlyName="eduPersonScopedAffiliation" encodeType="false" />
    </AttributeDefinition>
    <AttributeDefinition xsi:type="SubjectDerivedAttribute" id="usertype" principalAttributeName="usertype"></AttributeDefinition>
[root@www ~]# sudo systemctl restart tomcat9

        eduPersonTargtedID是一个永久可用的用户唯一id。通过hash算法加密之后,可读性不强。适用于需要区分不同用户的应用场景,同时保护了用户个人隐私。       

        修改eduPersonTargtedID加密盐值,可以使用如下指令生成随机字符串,并将idp.persistentId.salt = xxxxxxxxxxxxxxxxxxxx中的xxxxxxxxxxxxxxxxxxxx修改成生成的随机字符串

        注意:如果是进行IdP的升级,为了保证生成的eduPersonTargtedID一致,请沿用旧IdP的加密盐值,旧的加密盐值请参考IdP3.4.7备份恢复及高可用方案

[root@www ~]# openssl rand -base64 32
aesqnxtO+Di26xM78kXY6yD2m0QCK+0p68i7j7jQL8k=
[root@www ~]# vi /opt/shibboleth-idp/conf/saml-nameid.properties
idp.persistentId.sourceAttribute = eduPersonPrincipalName
idp.persistentId.salt = xxxxxxxxxxxxxxxxxxxx
idp.persistentId.encoding = BASE64
idp.persistentId.dataSource = MyDataSource

版权所有©北京大学计算中心