Shibboleth IdP v4 を使って cybozu.com との SAML 認証を設定する
はじめに
Shibboleth は、
学術認証フェデレーション
(学認:GakuNin)で利用している、シングルサインオンを実現するためのソフトウェアです。
Shibboleth を使って、cybozu.com へのシングルサインオンを行うための設定手順を説明します。
cybozu.com との連携に必要な設定箇所だけを記載しています。
Shibboleth IdP サーバーの構築方法の詳細は、
貴学にて IdPv4 をインストールする場合の構築手順(外部サイト)
を参照してください。
cybozu.com の SAML 認証は、 SP-initiated SSO として動作します。
動作環境
前提条件
- Shibboleth では IdP(Identify Provider)の機能を利用し、cybozu.com は SP(Service Provider)として動作します。
- Shibboleth IdP サーバーの構築、およびユーザー情報を管理するサーバーの構築は、行われているものとします。
検証環境
Shibboleth IdP v4.2.1 で動作を確認しています。
事前の準備
手順 1:cybozu.com 環境の準備
cybozu.com 環境を用意します。
環境がない場合は、
サイボウズドットコム ストア
から試用環境を申し込んでください。
「お試しになるサービス」は、任意のサービスを選択してください。
手順 2:ログインユーザーの追加
SAML 認証でログインするユーザーを追加します。
ユーザーを追加する手順は、
ユーザーを追加する
を参照してください。
例としてログイン名が「user」のユーザーを追加します。
手順 3:ServiceProvider メタデータファイルのダウンロード
cybozu.com を SP として Shibboleth IdP に登録するためのメタデータをダウンロードします。
このファイルは、あとの手順で使用します。
- cybozu.com にログインし、[cybozu.com 共通管理]を開きます。
- 「システム管理」の[ログイン]を開きます。
- 「SAML 認証を有効にする」のチェックボックスを選択します。
- 「Service Provider メタデータのダウンロード」をクリックして、メタデータファイルをダウンロードします。
- ファイル名を「cybozu-sp-metadata.xml」に変更します。
Shibboleth IdP での設定(IdP 側)
cybozu.com との連携するために、Shibboleth の設定ファイルを変更します。
以降、Shibboleth IdP は /opt/shibboleth-idp/
以下にインストールされているものとして記載します。
適宜インストールしているディレクトリーに合わせて読み替えてください。
手順 1:cybozu.com を SP として登録する
-
事前の準備でダウンロードしたメタデータファイルを、Shibboleth IdP サーバーに配置します。
配置する場所:/opt/shibboleth-idp/metadata/cybozu-sp-metadata.xml
-
/opt/shibboleth-idp/conf/metadata-providers.xml
を開きます。 -
ファイルの末尾に、次の内容を追記して保存します。
1 2 3 4 5 6 7 8 9 10 11
<!-- 以下の内容を追記する ここから --> <!-- cybozu.com --> <MetadataProvider id="cybozu" xsi:type="FilesystemMetadataProvider" xmlns="urn:mace:shibboleth:2.0:metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:mace:shibboleth:2.0:metadata http://shibboleth.net/schema/idp/shibboleth-metadata.xsd" failFastInitialization="true" metadataFile="/opt/shibboleth-idp/metadata/cybozu-sp-metadata.xml" maxRefreshDelay="PT48H"> </MetadataProvider> <!-- ここまで --> </MetadataProvider>
手順 2:アサーションの暗号化を解除する
Shibboleth IdP では、すべての SP に対して送信するアサーションは暗号化されます。
参考:
特定のSPへのアサーションを暗号化しない設定(外部サイト)
cybozu.com では、アサーションの暗号化に対応していないため、暗号化を解除します。
また、レスポンスに署名をするためアサーションへの署名も不要です。
-
/opt/shibboleth-idp/conf/relying-party.xml
を開きます。 -
<util:list id="shibboleth.RelyingPartyOverrides">
要素の中に、次の内容を追記して保存します。
<bean>
要素のc:relyingPartyIds
の値は、連携する cybozu.com の URL に変更してください。1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
<!-- 以下の内容を追記する ここから --> <!-- cybozu.com --> <bean parent="RelyingPartyByName" c:relyingPartyIds="https://sample.cybozu.com"> <property name="profileConfigurations"> <list> <bean parent="SAML2.SSO" p:encryptAssertions="false" p:signAssertions="true" p:signResponses="false" /> </list> </property> </bean> <!-- ここまで --> </util:list>
手順 3:NameID に cybozu.com でユーザーを識別するための要素を入れる
cybozu.com での SAML 認証では、SAML Response の NameID の値が cybozu.com の「ログイン名」と一致する必要があります。
Shibboleth では NameID として、ログインのたびに異なる ID(transientId)が割り当てられるため、ユーザーを一意に特定できません。
そのため、cybozu.com のログイン名と一致する値を NameID として受け渡します。
attribute-filter.xml
-
/opt/shibboleth-idp/conf/attribute-filter.xml
を開きます。 -
<AttributeFilterPolicyGroup>
要素の中に、次の内容を追記して保存します。
<PolicyRequirementRule>
要素のvalue
の値は、連携する cybozu.com の URL に変更してください。1 2 3 4 5 6 7 8 9 10
<!-- 以下の内容を追記する ここから --> <!-- cybozu.com --> <AttributeFilterPolicy id="cybozu"> <PolicyRequirementRule xsi:type="Requester" value="https://sample.cybozu.com" /> <!-- cybozu.com のログイン名がユーザーIDの場合 --> <AttributeRule attributeID="uid" permitAny="true" /> <!-- cybozu.com のログイン名がメールアドレスの場合 --> <AttributeRule attributeID="mail" permitAny="true" /> </AttributeFilterPolicy> <!-- ここまで -->
saml-nameid.xml
-
/opt/shibboleth-idp/conf/saml-nameid.xml
を開きます。 -
<util:list id="shibboleth.SAML2NameIDGenerators">
要素の中に、次の内容を追記して保存します。-
cybozu.com のログイン名に ID を利用する場合
1 2 3 4 5 6 7 8
<!-- SAML 2 NameID Generation --> <util:list id="shibboleth.SAML2NameIDGenerators"> <ref bean="shibboleth.SAML2TransientGenerator" /> <!-- 以下の内容を追記する ここから --> <bean parent="shibboleth.SAML2AttributeSourcedGenerator" p:format="urn:oasis:names:tc:SAML:1.1:nameid-format:username" p:attributeSourceIds="#{ {'uid'} }" /> <!-- ここまで -->
-
cybozu.com のログイン名にメールアドレスを利用する場合
1 2 3 4 5 6 7 8
<!-- SAML 2 NameID Generation --> <util:list id="shibboleth.SAML2NameIDGenerators"> <ref bean="shibboleth.SAML2TransientGenerator" /> <!-- 以下の内容を追記する ここから --> <bean parent="shibboleth.SAML2AttributeSourcedGenerator" p:format="urn:oasis:names:tc:SAML:1.1:nameid-format:username" p:attributeSourceIds="#{ {'mail'} }" /> <!-- ここまで -->
-
relying-party.xml
-
/opt/shibboleth-idp/conf/relying-party.xml
を開きます。 -
<util:list id="shibboleth.RelyingPartyOverrides">
要素の中に、次の内容を追記して保存します。1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
<!-- cybozu.com --> <bean parent="RelyingPartyByName" c:relyingPartyIds="https://sample.cybozu.com"> <property name="profileConfigurations"> <list> <bean parent="SAML2.SSO" p:encryptAssertions="false" p:signAssertions="true" p:signResponses="false" <!-- 以下の内容を追記する ここから --> p:nameIDFormatPrecedence="urn:oasis:names:tc:SAML:1.1:nameid-format:username" <!-- ここまで --> /> </list> </property> </bean> </util:list>
手順 4:Jetty の再起動
Shibboleth IdP の設定を変更したら、Jetty を再起動してください。
|
|
手順 5:SAMLResponse を確認する
SAMLResponse で、NameID のテキストが cybozu.com でユーザーを識別するための要素になっていることを確認します。
-
次のコマンドを実行します。
-
--principal
:cybozu.com と連携するユーザーのアカウント名 -
--requester
:cybozu.com の URL1 2
/opt/shibboleth-idp/bin/aacli.sh \ --principal=user --requester="https://sample.cybozu.com" --saml2
-
-
<saml2:Subject>
の要素の値が、cybozu.com のログイン名になっていることを確認します。
次の例では、5〜7 行目の<saml2:Subject>
の要素の値が、cybozu.com のログイン名「user」になっています。1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
<?xml version="1.0" encoding="UTF-8"?> <saml2:Assertion xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" ID="_68614df3778292ff49673274acf8ebc5" IssueInstant="2022-08-22T00:31:18.945Z" Version="2.0"> <saml2:Issuer>https://IdPのサーバー名/idp/shibboleth</saml2:Issuer> <saml2:Subject> <saml2:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:username" NameQualifier="https://IdPのサーバー名/idp/shibboleth" SPNameQualifier="https://sample.cybozu.com"> user </saml2:NameID> </saml2:Subject> <saml2:AttributeStatement> <saml2:Attribute FriendlyName="schacHomeOrganization" Name="urn:oid:1.3.6.1.4.1.25178.1.2.9" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"> <saml2:AttributeValue>compute-1.amazonaws.com</saml2:AttributeValue> </saml2:Attribute> <saml2:Attribute FriendlyName="uid" Name="urn:oid:0.9.2342.19200300.100.1.1" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"> <saml2:AttributeValue>user</saml2:AttributeValue> </saml2:Attribute> <saml2:Attribute FriendlyName="mail" Name="urn:oid:0.9.2342.19200300.100.1.3" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"> <saml2:AttributeValue>user@example.com</saml2:AttributeValue> </saml2:Attribute> </saml2:AttributeStatement> </saml2:Assertion>
cybozu.com での設定(SP 側)
手順 1:公開鍵の証明書ファイルを取得する
Shibboleth IdP のサーバーから、SAML の署名に利用する公開鍵の証明書ファイルを取得します。
/opt/shibboleth-idp/conf/idp.properties
の idp.signing.cert
に指定している証明書ファイルです。
手順 2:cybozu.com へ Shibboleth IdP の情報を登録する
Identity Provider(IdP)の情報を設定する手順の詳細は、
STEP2:cybozu.comでSAML認証を設定する
を参照してください。
- cybozu.com にログインし、[cybozu.com 共通管理]を開きます。
- 「システム管理」の[ログイン]を開きます。
- 「SAML 認証を有効にする」のチェックボックスを選択します。
- IdP の情報を入力します。
- Identity ProviderのSSOエンドポイントURL:
https://IdPのサーバー名/idp/profile/SAML2/Redirect/SSO
- cybozu.comからのログアウト後に遷移するURL:
cybozu.com からログアウトした後に表示される IdP の URL
- Identity ProviderのSSOエンドポイントURL:
- 「証明書を登録する」の[参照]をクリックし、公開鍵の証明書ファイルを指定します。
- [保存]をクリックします。
動作確認
SAML 認証を使用して cybozu.com にシングルサインオンできることを確認します。
次の操作ができれば完了です。
- Web ブラウザーで cybozu.com にアクセスすると、IdP の認証に成功し、ログイン後の画面が表示される。
- 正常にログアウトできる。
SAML 認証の設定に失敗して cybozu.com にログインできなくなった場合には、
SAML 認証を回避する URL
から cybozu.com にログインして、SAML 認証の設定を見直してください。
この Tips 2022 年 11 月版 cybozu.com および Shibboleth IdP v4.2.1 で確認した内容です。