OpenAM配下にShibboleth-SPを連携(例:Sympa)¶
SPのインストール¶
- アプリケーションサーバ側にShibbolethSPを導入
 https://secure.nanako-net.info/redmine/projects/know-how/wiki/Shibboleth-SP
- ここでは省略
IdPにSPを登録¶
- OpenAMを操作している端末のブラウザで下記URLをひらき、メタデータをダウンロードする
 https://sp.example.com/Shibboleth.sso/Metadata
- OpenAMの画面で「Federation」画面を開く
- エンティティプロバイダの「エンティティのインポート」を実行する
- 「メタデータはどこに存在しますか」に「ファイル」を選択し、前述の「Metadata」をアップロードする
- SPが登録されることを確認する
- トラストサークルの中のsamlを開く
- エンティティプロバイダにSPが登録されているので、選択して有効化する
SPにIdPを登録¶
- アプリケーションサーバで下記コマンドを実行し、IdPのメタデータをダウンロードする# wget --no-check-certificate https://idp.example.com/openam/saml2/jsp/exportmetadata.jsp 
- 取得したメタデータをリネームし、配置する# mv exportmetadata.jsp /etc/shibboleth/idpMetadata.xml 
- メタデータを設定ファイルに登録する# vi /etc/shibboleth/shibboleth2.xml ----------------------------- ※OpenAMのエンティティIDを記載。DSは使わないため削除しSAMLを直接指定 ※OpenAM側のエンティティプロバイダ名にポート番号がある場合はポート番号も必要 <SSO entityID="https://idp.example.com:443/openam"> SAML2 SAML1 </SSO> ※/etc/shibbolethの相対パスでメタデータのファイルパスを記入 <!-- Example of locally maintained metadata. --> <MetadataProvider type="XML" validate="true" path="idpMetadata.xml"/>
- ShibbolethSPを再起動する# systemctl restart shibd 
- OpenAMのWeb画面でフェデレーションを開き、トラストサークルプロファイルを開く。
- SPのエンティティプロバイダがリストに追加されているので、有効にする。
OpenAMとShibboleth-SPの連携¶
ログインID属性としてアプリケーションにメールアドレスを渡すように変更する
(デフォルトのnameidは一意なランダムな文字列が設定される)
Shibboleth-SPのマッピング設定¶
- Shibbolethがアプリケーションに渡すIDを環境変数mailに設定する# vi /etc/shibboleth/shibboleth2.xml ----------------------------- <ApplicationDefaults entityID="https://sp.example.com/shibboleth-sp" REMOTE_USER="mail" cipherSuites="DEFAULT:!EXP:!LOW:!aNULL:!eNULL:!DES:!IDEA:!SEED:!RC4:!3DES:!kRSA:!SSLv2:!SSLv3:!TLSv1:!TLSv1.1">
- ログイン成功時に渡されるnameidをmailにマッピングするよう設定する
 ここではpersistentをmailにマッピングするので、下記内容でファイルを新規作成する。# mv /etc/shibboleth/attribute-map.xml /etc/shibboleth/attribute-map.xml_old # vi /etc/shibboleth/attribute-map.xml ----------------------------- <Attributes xmlns="urn:mace:shibboleth:2.0:attribute-map" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Attribute name="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent" id="mail"> <AttributeDecoder xsi:type="NameIDAttributeDecoder" formatter="$Name" defaultQualifiers="true"/> </Attribute> </Attributes>
- ShibbolethSPを再起動する# systemctl restart shibd 
- openamの「Fadaration」画面を開く
- エンティティープロバイダでidpの設定を開く
- 「NameIDの書式」のNameIDの書式リストにattribute-mapに追加した属性の書式のみに設定するurn:oasis:names:tc:SAML:2.0:nameid-format:persistent 
- 「NameIDの書式」のNameIDのマップにattribute-mapに追加した属性のマップのみに設定するurn:oasis:names:tc:SAML:2.0:nameid-format:persistent=mail 
- 設定を保存して閉じる
アプリケーション連携試験¶
- OpenAMのWeb画面で「TopLevelRealm」→「Subjects」に移動
- 「新規」でユーザを作成
- 作成後に再度ユーザを開き、メールアドレスを入力
- 下記LDAPに接続し、情報が登録されることおよび内容を確認URL idp.example.com:50389 BindDN cn=Directory Manager BaseDN dc=openam,dc=example,dc=com 
- テストプログラムに必要なphpを導入する# yum install php # systemctl restart httpd 
- SPの以下のパスに次のテストプログラムを配置する# mkdir /var/www/html/secure/ # vi /var/www/html/secure/index.php ----------------------------- <?php echo $_SERVER["mail"]; ?> 
- ブラウザのプライベートウインドウ(常に新規セッションのため)を起動し次のURLを実行する
 https://sp.example.com/secure/index.php
- openamのログイン画面にリダイレクトされる
- メールアドレスが正しく取得できることを確認する
アプリケーション(Sympa)との連携¶
SympaにShibboleth認証要求を設定¶
- sympaの認証設定をローカルDBからSSOに変更# vi /etc/sympa/auth.conf ----------------------------- generic_sso service_name InQueue Federation service_id inqueue http_header_prefix mail email_http_header mail logout_url https://sp.example.com/Shibboleth.sso/Logout email_attribute mail #既存最終行付近はコメントアウト #user_table # regexp .*- logout_urlを記載しておくと、ログアウト処理でこのURLを参照してくれる。
- 仮想ドメインの場合「/etc/sympa/ドメイン名」ディレクトリにauth.confをコピーすること
 
- ShibbolethSPがSSO成功後にSympaにリダイレクトした際、上記「inqueue」にアクセスしSympaのログイン状態を有効化するように「target=アドレス」としてリダイレクト先設定する。
 このリダイレクト先はRelayStateと呼ばれるもので、IDP側で設定するケースとSP側で設定するケース両方ある。今回は後者# vi /etc/shibboleth/shibboleth2.xml -------------------- <SSO entityID="https://idp.example.com:443/openam" target="https://sp.example.com/sympa/sso_login/inqueue/init"> SAML2 SAML1 </SSO> <!-- <Logout>SAML2 Local</Logout> --> <Logout>Local</Logout>- シングルログアウトは必要がなければコメントアウト
 
- httpdに上記SSOでアクセスした場合にShibbolethを使用する設定を追加# vi /etc/httpd/conf.d/sympa.conf <Location /static-sympa> Require all granted </Location> <Location /sympa/sso_login/inqueue> AuthType shibboleth ShibRequestSetting requireSession 1 require shib-session </Location>- 「/sympa/sso_login/inqueue」は「/sympa」にするとログインボタン前に認証になる
 
- httpdを再起動する# systemctl restart httpd 
- 下記アドレスにアクセスする
 https://sp.example.com/sympa
- 右上のログインボタンが認証設定で変更した「InQueue Federation」になっていること
- ボタンを押した際にOpenAMにリダイレクトすること
- ログイン後、右上のユーザ名がメールアドレスになっていること