この文書にはuApprove Jet Pack 3.2(以下、「uApprove JP」) のインストールガイドと総合マニュアルが記されています。

uApprove JPはShibboleth Identity Provider 3を拡張するプラグインです。uApprove Jet Pack 2.5で提供していた機能の一部をShibboleth Identity Provider 3でも利用できるようにすることを目的としています。これを利用することにより、利用者はIdentity Providerで認証する際に、属性を選択的に送信することができます。 uApprove JPのコンセプトに関するより詳細な情報はこちらを参照してください。

本ガイドに関する注意事項:


目次

想定

前提条件

1 基本的なデプロイ

1.1 ライブラリのインストール

ライブラリをIdPのライブラリディレクトリにコピーします:

# cp $UAPPROVE_INSTALL$/lib/*.jar $IDP_HOME$/edit-webapp/WEB-INF/lib/

$IDP_HOME$/edit-webapp/WEB-INF/libにはそれぞれのライブラリの単一のバージョンのみが存在するようにしてください。

1.2 Velocity テンプレートファイル

属性選択画面用のVelocityテンプレートファイルをIdPのviewsディレクトリに上書きコピーします:

# cp $UAPPROVE_INSTALL$/manual/examples/views/intercept/* $IDP_HOME$/views/intercept

1.3 CSS ファイル

CSSファイルをIdPのedit-webappディレクトリにコピーします:

# cp $UAPPROVE_INSTALL$/manual/examples/edit-webapp/css/* $IDP_HOME$/edit-webapp/css

1.4 設定のカスタマイズ

$IDP_HOME$/conf/idp.propertiesに、以下の変更を行います。idp.consent.allowPerAttributeidp.consent.compareValuesの値をtrueに設定してください:

...

# Flags controlling how built-in attribute consent feature operates

#idp.consent.allowDoNotRemember = true

#idp.consent.allowGlobal = true

idp.consent.allowPerAttribute = true

 

# Whether attribute values and terms of use text are compared

idp.consent.compareValues = true

...

$IDP_HOME$/conf/global.xmlに、以下の属性選択画面で使用するbean定義を追加します:

 ...

<bean id="shibboleth.FallbackLanguages" parent="shibboleth.CommaDelimStringArray" c:_0="#{'%{idp.ui.fallbackLanguages:}'.trim()}" />

<util:map id="shibboleth.CustomViewContext">

    <entry key="OptionalAttributeFunction">

        <bean class="jp.gakunin.idp.consent.logic.impl.OptionalAttributeFunction" />

    </entry>

    <entry key="AttributeIntendedUseFunction">

        <bean class="jp.gakunin.idp.consent.logic.impl.AttributeIntendedUseFunction" p:defaultLanguages-ref="shibboleth.FallbackLanguages" />

    </entry>

</util:map>

...

$IDP_HOME$/system/conf/services-system.xmlに、以下の変更を行います。id="shibboleth.AttributeFilterService"bean定義の<constructor-arg name="strategy">を以下のように変更してください:

この変更は、Shibboleth Identity Providerを再インストール(アップグレード等)する際に上書きされるため、再インストールを行った際には、再度変更を行う必要があります。

...

<bean id="shibboleth.AttributeFilterService" class="net.shibboleth.ext.spring.service.ReloadableSpringService"

        depends-on="shibboleth.VelocityEngine"

        p:serviceConfigurations-ref="#{'%{idp.service.attribute.filter.resources:shibboleth.AttributeFilterResources}'.trim()}"

        p:failFast="%{idp.service.attribute.filter.failFast:%{idp.service.failFast:false}}"

        p:reloadCheckDelay="%{idp.service.attribute.filter.checkInterval:PT0S}"

        p:beanFactoryPostProcessors-ref="shibboleth.PropertySourcesPlaceholderConfigurer">

    <constructor-arg name="claz" value="net.shibboleth.idp.attribute.filter.AttributeFilter" />

    <constructor-arg name="strategy">

        <bean class="jp.gakunin.idp.attribute.filter.spring.impl.AttributeFilterServiceStrategy"

id="ShibbolethAttributeFilter"/>

    </constructor-arg>

</bean>

...

$IDP_HOME$/system/flows/intercept/attribute-release-beans.xmlに、以下の変更を行います。id="IsConsentRequiredPredicate"bean定義のclassを変更してください:

この変更は、Shibboleth Identity Providerを再インストール(アップグレード等)する際に上書きされるため、再インストールを行った際には、再度変更を行う必要があります。

...

<bean id="IsConsentRequiredPredicate"

    class="jp.gakunin.idp.consent.logic.impl.IsConsentRequiredPredicate" />

...

1.5 カスタムテンプレート

テンプレートをカスタマイズしたい場合は、 テンプレートのカスタマイズ を参照してください。

少なくとも、所属機関のロゴを変更する必要があります。デフォルトではこのファイルはプレースホルダのロゴになっています。

ロゴをデフォルトのOur Identity Providerから機関のロゴに変更するには、以下の手順を行ってください

  1. ロゴファイル organization-logo.png$IDP_HOME$/edit-webapp/images/以下に配置します:

    $ ls $IDP_HOME$/edit-webapp/images/
    dummylogo-mobile.png  dummylogo.png  organization-logo.png
  2. $IDP_HOME$/messages/error-messages.propertiesidp.logoを上記1.で配置したファイル名に変更します。なお、ファイル名は/images/から始めます。また、idp.logo.alt-textを変更します:

    idp.logo = /images/organization-logo.png

    idp.logo.alt-text = Organization logo

  3. $IDP_HOME$/bin/build.shを実行して、$IDP_HOME$/war/idp.warを作り直します:

    $ cd $IDP_HOME$
    $ sudo -u tomcat env JAVA_HOME="${JAVA_HOME}" bin/build.sh
    Installation Directory: [/opt/shibboleth-idp]
    
    Rebuilding /opt/shibboleth-idp/war/idp.war ...
    ...done
    
    BUILD SUCCESSFUL
    Total time: 16 seconds

1.6 ログの設定

uApprove JPのログを出力するには、$IDP_HOME$/conf/logback.xmlに以下を追加します:

...

<!-- Logging level shortcuts. -->

<variable name="idp.loglevel.uApproveJP" value="INFO" />

...

<!-- =========================================================== -->

<!-- ============== Logging Categories and Levels ============== -->

<!-- =========================================================== -->

<logger name="jp.gakunin.idp" level="${idp.loglevel.uApproveJP:-INFO}"/>

...

1.7 デプロイ

IdP で uApprove JP を有効にするには IdP を再デプロイする必要があります:

# cd $IDP_HOME$
# ./bin/build.sh
Installation Directory: [/opt/shibboleth-idp]
[Enter] ←入力なし
Rebuilding /opt/shibboleth-idp/war/idp.war ...
...done

BUILD SUCCESSFUL
Total time: 16 seconds

$CATALINA_BASE$/conf/Catalina/localhost/idp.xmlが存在しない場合は、追加の作業としてidp.war$CATALINA_BASE$/webappsにコピーします:

# ls $CATALINA_BASE$/conf/Catalina/localhost/idp.xml
ls: cannot access /usr/java/tomcat/conf/Catalina/localhost/idp.xml: そのようなファイルやディレクトリはありません
# cp $IDP_HOME$/war/idp.war $CATALINA_BASE$/webapps/

Tomcatを再起動します:

# service tomcat7 restart

2 高度なデプロイ

この節では高度な設定についてのトピックを取り上げます。

2.1 リレーショナルデータベースを用いたユーザ同意情報の保存

リレーショナルデータベース(以下、「RDB」とします)を用いて、ユーザ同意情報の保存を行うことができます。

2.1.1. MySQLの設定

以下のデータベースパラメータは一例です。実際の値は必要に応じて変更してください。特にパスワードは安全なものを用意してください。

MySQLの設定を行います。

  1. データベース shibbolethの作成
    Shibboleth IdPで使用するデータベース shibbolethを作成します:

    db$ mysql -u root
    mysql>
    CREATE DATABASE shibboleth;

  2. ユーザ作成
    IdPからデータベース shibbolethにアクセスするためのユーザ shibbolethを作成し、データベース shibbolethへの権限を付与します:

    db$ mysql -u root
    mysql>
    CREATE USER 'shibboleth'@'localhost' IDENTIFIED BY 'shibpassword';           # ←任意のパスワード
    GRANT INSERT, SELECT, UPDATE, DELETE ON shibboleth.* TO 'shibboleth'@'localhost';

  3. StorageRecordsテーブル作成

    JPAStorageServiceが使用するテーブル StorageRecordsを作成します:

    db$ mysql -u root
    mysql>
    use shibboleth;
    CREATE TABLE `StorageRecords` (
        `context` varchar(255) NOT NULL,
        `id` varchar(255) NOT NULL,
        `expires` bigint(20) DEFAULT NULL,
        `value` longtext NOT NULL,
        `version` bigint(20) NOT NULL,
        PRIMARY KEY (`context`,`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

2.1.3. MySQL Connector/Jのインストール

  1. MySQLへのアクセスに必要なMySQL Connector/J(mysql-connector-java.jar)をインストールします:

    # yum install mysql-connector-java
  2. /usr/share/java配下にインストールされているので、edit-webapp/ 配下のlibディレクトリにシンボリックリンクを作成します:

    # rpm -ql mysql-connector-java
    (省略)
    /usr/share/java/mysql-connector-java.jar
    (省略)
    # ln -s /usr/share/java/mysql-connector-java.jar $IDP_HOME$/edit-webapp/WEB-INF/lib/
  3. 1.7 デプロイの手順に従って再デプロイします。

2.1.4. idp.consent.StorageServiceの設定変更

idp.consent.StorageServiceの設定をshibboleth.JPAStorageServiceに変更します:

5行目の変更は3.1まで向けのものです。3.2以降では不要です(デフォルトでサーバサイドでは無制限に記憶されます)。

# Set to "shibboleth.StorageService" or custom bean for alternate storage of consent 

idp.consent.StorageService = shibboleth.JPAStorageService
# Maximum number of consent storage records
# Set to -1 for unlimited server-side storage
idp.consent.maxStoredRecords = -1

2.1.5. shibboleth.JPAStorageServiceの設定

2.1.4. idp.consent.StorageServiceの設定変更idp.sesssion.StorageServiceに設定したshibboleth.JPAStorageServiceを定義します。

id="Shibboleth.MySQLDataSource"bean定義のp:url, p:username, p:passwordは、2.1.1. MySQLの設定に合わせて設定します:

<!-- Use this file to define any custom beans needed globally. -->
<bean id="shibboleth.JPAStorageService"
      class="org.opensaml.storage.impl.JPAStorageService"
      p:cleanupInterval="%{idp.storage.cleanupInterval:PT10M}"
      c:factory-ref="shibboleth.JPAStorageService.entityManagerFactory" />

<bean id="shibboleth.JPAStorageService.entityManagerFactory"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
     <property name="packagesToScan" value="org.opensaml.storage.impl" />
     <property name="dataSource" ref="shibboleth.MySQLDataSource" />
     <property name="jpaVendorAdapter" ref="shibboleth.JPAStorageService.JPAVendorAdapter" />
     <property name="jpaDialect">
          <bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
     </property>
</bean>

<bean id="shibboleth.JPAStorageService.JPAVendorAdapter"
      class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
      p:database="MYSQL" />

<bean id="shibboleth.MySQLDataSource"
      class="org.apache.tomcat.dbcp.dbcp.BasicDataSource"
      p:driverClassName="com.mysql.jdbc.Driver"
      p:url="jdbc:mysql://localhost:3306/shibboleth"
      p:username="shibboleth"
      p:password="shibpassword"
      p:maxActive="10"
      p:maxIdle="5"
      p:maxWait="15000"
      p:testOnBorrow="true"
      p:validationQuery="select 1"
      p:validationQueryTimeout="5" />

2.1.6. Tomcatの再起動

Tomcatを再起動します:

# service tomcat7 restart

2.2 テンプレート

テンプレートのカスタマイズ

$IDP_HOME$/views/にある Velocityテンプレートファイル 、 $IDP_HOME$/edit-webapp/にあるCSS や画像ファイルは自由にカスタマイズすることができます。 Velocity を用いているので容易にカスタマイズ出来るようになっています。

Velocity については Velocity User Guide を参照してください。

2.3 ローカライズ

カスタムメッセージ

以下の記述はShibboleth IdP 3.2.1およびそれ未満向けです。3.3.0およびそれ以降では次のリンク先を参照してください。
GakuNinShare:Shibboleth IdP 3 - メッセージの多言語化

$IDP_HOME$/messages/に用意されているリソースバンドルは環境に合わせたり、修正することができます。

$IDP_HOME$/messages/以下のファイルを追加、または修正した場合はTomcatの再起動が必要です。

$UAPPROVE_INSTALL$/manual/examples/messages/に、日本語環境用のテンプレートファイルが用意されています。

$IDP_HOME$/messages/にファイルをコピーすることで日本語メッセージを表示するようになります:

# cp $UAPPROVE_INSTALL$/manual/examples/messages/* $IDP_HOME$/messages/
# service tomcat7 restart

Relying Partyの名前と説明

現状では、ローカライズされた Relying Party の名前と説明を取得する際には、メタデータのうち<AttributeConsumingService>要素および<mdui:UIInfo>要素がサポートされています。

この名前と説明を使用する場合は、SPのメタデータを以下のように記述します:

<EntityDescriptor entityID="https://sp.example.org/shibboleth">

    <!-- ... -->

    <SPSSODescriptor>

        <Extensions>

            <mdui:UIInfo xmlns:mdui="urn:oasis:names:tc:SAML:metadata:ui">

                <mdui:DisplayName xml:lang="en">Example SP</mdui:DisplayName>

                <!-- Service names in other languages -->

                <mdui:Description xml:lang="en">Some description of Example SP</mdui:Description>

                <!-- Service descriptions in other languages -->

            </mdui:UIInfo>

        </Extensions>

        <!-- ... -->

        <AttributeConsumingService index="1">

            <ServiceName xml:lang="en">Example SP</ServiceName>

            <!-- Service names in other languages -->

            <ServiceDescription xml:lang="en">Some description of Example SP</ServiceDescription>

            <!-- Service descriptions in other languages -->

        </AttributeConsumingService>

    </SPSSODescriptor>

</EntityDescriptor>

両方記載されている場合には<mdui:UIInfo>要素が優先されます。

学認のSPについても海外SPの一部を除いてこの情報が含まれています。

2.4 AttributeInMetadataマッチングルール

AttributeInMetadataマッチングルールの設定

このルールは、SP がその属性を必要とした場合に、そのメタデータにより属性の送信を許可します。属性は<SPSSODescriptor>中の<AttributeConsumingService>によって示されます。 <RequestedAttribute>isRequired="true"を記述した属性は必須とマークされ、isRequired="false"を記述した属性はオプションとマークされます。詳細は SAMLメタデータを参照してください。

以下の点に注意してください:

  • このフィルタの利用には属性の要求者のメタデータがロードされ利用可能である必要があります。
  • 要求者のメタデータは<SPSSODescriptor>ロールを持っている必要があります。このロールがリストされた属性を持っているためです。
  • AttributeInMetadataマッチングルールは値のルールとしてのみ働き、<PermitValueRule>の場合のみ意味をなします。

名前空間の定義

属性フィルタのポリシーにおいて、このプラグイン用に名前空間の定義を加える必要があります。以下のように行います:

ルールの定義

このルールは<PermitValueRule xsi:type="uajpmf:AttributeInMetadata">のように記述します。以下のオプショナルな属性を使用できます:

onlyIfRequired

必須とマークされた属性のみ送信を許可し、オプションとマークされたものは送信しないブーリアンフラグです。

デフォルト値は true です。

matchIfMetadataSilent

メタデータに <AttributeConsumingService> がない場合にオプションとマークするかどうかを決定するブーリアンフラグです。

デフォルト値は false です。

onlyIfChecked

オプションとマークされた属性の送信を利用者が許可/拒否できるかどうかを示すブーリアンフラグです。
false の時の動作は Shibboleth IdP 3.2.0 以降の AttributeInMetadata と同一になり、オプションとマークされた属性も必須とマークされた属性と同様にチェックボックスなしで表示されます。

デフォルト値は false です。 

AttributeInMetadataマッチファンクションを使用した<PermitValueRule>の書き方は下記のようになります:

<PermitValueRule xsi:type="uajpmf:AttributeInMetadata" onlyIfRequired="false"
                 onlyIfChecked="true">

オプションとマークされた属性をチェックボックスつきで表示します。チェックボックスをチェックしたときだけ送信します。

AttributeInMetadataマッチファンクションを使用した<PermitValueRule>の設定例を示します:

<!--    ==================================================================================
case 1: mail 属性、eduPersonPrincipalName属性、eduPersonAffiliation属性を、メタデータの
        定義と照合するルールです。

        メタデータでisRequired="true"が指定されている属性は、すべて必須情報になり常に
        送信されます。

        メタデータでisRequired="false"が指定されている属性は以下の通りです。
        * mail属性は必須情報となり常に送信されます。
        * eduPersonPrincipalName属性はオプション情報となります。属性選択画面ではチェック
          ボックスつきで表示されます。利用者がチェックボックスをチェックした場合に限り送信
          されます。
        * eduPersonAffiliation属性は送信されません。

        メタデータにAttributeConsumingServiceをもたないSPの場合はどの属性も送信しません。
        ================================================================================== -->
<afp:AttributeFilterPolicy id="PolicyforSPwithAttributeConsumingService">
    <afp:PolicyRequirementRule xsi:type="basic:ANY" />

    <afp:AttributeRule attributeID="mail">
        <afp:PermitValueRule xsi:type="uajpmf:AttributeInMetadata"
                             onlyIfRequired="false" />
    </afp:AttributeRule>

    <afp:AttributeRule attributeID="eduPersonPrincipalName">
        <afp:PermitValueRule xsi:type="uajpmf:AttributeInMetadata"
                             onlyIfRequired="false"
                             onlyIfChecked="true" />
    </afp:AttributeRule>

    <afp:AttributeRule attributeID="eduPersonAffiliation">
        <afp:PermitValueRule xsi:type="uajpmf:AttributeInMetadata" />
    </afp:AttributeRule>

</afp:AttributeFilterPolicy>

<!--    ==================================================================================
case 2: メタデータに AttributeConsumingServiceがないSPに対するルールを追加したルール
        です。

        AttributeConsumingService要素を持たないSPの場合は以下の通りです。
        * mail属性は必須情報となり常に送信されます。
        * eduPersonPrincipalName属性はオプション情報となります。属性選択画面ではチェック
          ボックスつきで表示されます。利用者がチェックボックスをチェックした場合に限り送信
          されます。
        * eduPersonAffiliation属性は送信されません。

        AttributeConsumingService要素を持つSPの場合はcase 1と同じです。
        ================================================================================== -->
<afp:AttributeFilterPolicy id="PolicyforSPwithoutAttributeConsumingService">
    <afp:PolicyRequirementRule xsi:type="basic:ANY" />

    <afp:AttributeRule attributeID="mail">
        <afp:PermitValueRule xsi:type="uajpmf:AttributeInMetadata"
                             matchIfMetadataSilent="true"
                             onlyIfRequired="false" />
    </afp:AttributeRule>

    <afp:AttributeRule attributeID="eduPersonPrincipalName">
        <afp:PermitValueRule xsi:type="uajpmf:AttributeInMetadata"
                             matchIfMetadataSilent="true"
                             onlyIfRequired="false"
                             onlyIfChecked="true" />
    </afp:AttributeRule>

    <afp:AttributeRule attributeID="eduPersonAffiliation">
        <afp:PermitValueRule xsi:type="uajpmf:AttributeInMetadata" />
    </afp:AttributeRule>

</afp:AttributeFilterPolicy>

3 トラブルシューティング

3.1 トラブルシューティング

3.2 詳細なログ設定

DEBUG ないしTRACEログレベルを有効にしたい場合は、$IDP_HOME$/conf/idp.propertiesにて以下を追加します:

idp.loglevel.uApproveJP = DEBUG

A SPでの属性使用用途通知

SP管理者はSPのメタデータに属性の使用用途を記述することで、SPの利用者に属性の使用用途 (例えば、プロファイルの初期値として使用) をuApprove JPで表示することができます。

A.1 設定

属性使用用途通知機能は、<RequestedAttribute>uajpmd:description属性を追加する、または、<SPSSODescriptor><Extensions><uajpmd:RequestedAttributeExtension>を追加することで利用できます。

<uajpmd:RequestedAttributeExtension>は多言語に対応しています。また、一つの属性に両方が設定されている場合は、<uajpmd:RequestedAttributeExtension>が優先されます。

uajpmd:description

この属性は<ResquestedAttribute>にて定義します:

uajpmd:description

属性の使用用途の文字列です。

uajpmd:descrptionを使用した<RequestedAttribute>の設定例:

<md:RequestedAttribute FriendlyName="mail"
        Name="urn:oid:0.9.2342.19200300.100.1.3"
        NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"
        uajpmd:description="The mail attribute is used as the initial value of the mail address field of the registration form."/>

<uajpmd:RequestedAttributeExtension>

<uajpmd:RequestedAttributeExtension>は以下の必須属性と一つ以上の<uajpmd:Description>と共に設定します:

uajpmd:FriendlyName関連づけたい<RequestedAttribute>FriendlyName属性の値です。

<uajpmd:Description>には属性の使用用途を記述します。<uajpmd:RequestedAttributeExtension>は以下の必須属性と共に設定します:

xml:lang

属性の使用用途の言語です。

<uajpmd:RequestedAttributeExtension>の設定例:

<md:EntitiesDescriptor Name="uapprovejp-dev-metadata.xml"
                    xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
                    xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
                    xmlns:shibmd="urn:mace:shibboleth:metadata:1.0"
                    xmlns:uajpmd="http://www.gakunin.jp/ns/uapprove-jp/metadata"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  ...
  <md:EntityDescriptor entityID="...">
    <md:SPSSODescriptor>
      ...

      <md:Extensions>
        ...
        <uajpmd:RequestedAttributeExtension FriendlyName="mail">
          <uajpmd:Description xml:lang="en">The mail attribute is used as the initial value of the mail address field of the registration form.</uajpmd:Description>
          <uajpmd:Description xml:lang="ja">mail 属性を登録ページのメールアドレス欄の初期値として使用します</uajpmd:Description>
        </uajpmd:RequestedAttributeExtension>
        ...
      </md:Extensions>
      ...

      <md:AttributeConsumingService index="1">
      	<md:ServiceName xml:lang="en">Sample Service</md:ServiceName>

        <md:RequestedAttribute FriendlyName="eduPersonPrincipalName"
                               Name="urn:oid:1.3.6.1.4.1.5923.1.1.1.6"
                               NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"
                               isRequired="true"/>
        <md:RequestedAttribute FriendlyName="mail"
                               Name="urn:oid:0.9.2342.19200300.100.1.3"
                               NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"/>
      </md:AttributeConsumingService>
      ...
    </md:SPSSODescriptor>
    ...
  </md:EntityDescriptor>
  ...
</md:EntitiesDescriptor>