0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

attribute-filter.xml では属性値を変更できない

Posted at

概要

Shibboleth IdPで特定のSPに対してだけ、送出する属性値に細工をしようとしたら出来なかった。attribute-filter.xml では属性値の送出をフィルタするだけで、追加や変更はできない。
https://wiki.shibboleth.net/confluence/display/IDP30/AttributeFilterConfiguration にその旨が記載されている。

解説

Shibboleth SPの中には、特定の属性値を送出してきたユーザに対し、IdPの管理者として扱う様なサービスがある。この方法を取ると、SPでサービスを提供する側は、IdPの管理者に誰が管理者であるかを個別に確認する必要が無い。
例えば、倫倫姫では、eduPersonEntitlement=urn:mace:nii.ac.jp:moodle:course-admin のユーザをコース管理者権限として扱うようになっていた。

解説では attribute-resolver.xml で条件式を書き、特定のuidを持つユーザに対して属性値を変更する様に記載があるが、その方法だとどのSPに対しても同じ属性値を送出してしまうため、attribute-filter.xml で処理したらSP毎に設定することが可能になると考えた(が、ダメだった)。

attribute-filter.xml の設定 (Shibboleth IdP 3.6)

今後役に立つかも知れないので、メモとして attirbiute-filter.xml の設定を残す。
Shibbboleth IdPのバージョンにより、XMLの書式が変わることに注意。また、Javascriptの扱いが利用しているJREにより変わることにも注意。今回はJava 8で記述。

attribute-resolver.xml において、eduPersonEntitlement=urn:mace:dir:entitlement:common-lib-terms;mace:nii.ac.jp:moodle:course-admin となっていない場合には、期待した様な動作は得られない。
この場合は、eduPersonEntitlementurn:mace:dir:entitlement:common-lib-terms のみ返ってくる。

conf/attribute-filter.xml
<AttributeFilterPolicy id="PolicyforYourSP">
    <PolicyRequirementRule xsi:type="Requester" value="https://sp-host.domain/shibboleth-sp" />
    <AttributeRule attributeID="eduPersonPrincipalName" permitAny="true" />
    <AttributeRule attributeID="eduPersonTargetedID" permitAny="true" />

    <!-- 全てのユーザで eduPersonEntitlement を送出する場合
    <AttributeRule attributeID="eduPersonEntitlement" permitAny="true" />
    -->
    
    <!-- 条件に合致する場合のみ eduPersonEntitlement を送出 -->
    <AttributeRule attributeID="eduPersonEntitlement">
        <!-- 全てのユーザで送出
        <PermitValueRule xsi:type="ANY" />
        -->

        <!-- 特定のuidの場合にのみ送出
        <PermitValueRule xsi:type="Value" attributeID="uid" value="test001" />
        -->

        <!-- 特定の複数のuidの場合にのみ送出
        <PermitValueRule xsi:type="OR">
            <Rule xsi:type="Value" attributeID="uid" value="test001" />
            <Rule xsi:type="ValueRegex" attributeID="uid" regex="^.*001$" />
        </PermitValueRule>
        -->

        <!-- Javascriptで条件を定義 -->
        <PermitValueRule xsi:type="Script">
            <Script>
                <![CDATA[
                    hashSetType = Java.type("java.util.LinkedHashSet");
                    StringAttributeValue = Java.type("net.shibboleth.idp.attribute.StringAttributeValue");

                    result = new hashSetType();
                    result.add(new StringAttributeValue("urn:mace:dir:entitlement:common-lib-terms"));

                    if (uid == 'test001') {
                        result.add(new StringAttributeValue("urn:mace:nii.ac.jp:moodle:course-admin"));
                    }
                    result;
                ]]>
            </Script>
        </PermitValueRule>
    </AttributeRule>
</AttributeFilterPolicy>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?