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が登録されることを確認する
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を直接指定 <SSO entityID="https://idp.example.com/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にマッピングするよう設定する
1. persistentをmailにマッピング
2. 不要な属性をコメントアウト# vi /etc/shibboleth/attribute-map.xml ----------------------------- <Attribute name="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent" id="mail"> <AttributeDecoder xsi:type="NameIDAttributeDecoder" formatter="$Name" defaultQualifiers="true"/> </Attribute> <!-- The eduPerson attribute version (note the OID-style name): --> <!-- <Attribute name="urn:oid:1.3.6.1.4.1.5923.1.1.1.10" id="persistent-id"> <AttributeDecoder xsi:type="NameIDAttributeDecoder" formatter="$NameQualifier!$SPNameQualifier!$Name" defaultQualifiers="true"/> </Attribute> --> <!-- The SAML 2.0 NameID Format: --> <!-- <Attribute name="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent" id="persistent-id"> <AttributeDecoder xsi:type="NameIDAttributeDecoder" formatter="$NameQualifier!$SPNameQualifier!$Name" defaultQualifiers="true"/> </Attribute> <Attribute name="urn:oid:1.3.6.1.4.1.5923.1.1.1.1" id="unscoped-affiliation"> <AttributeDecoder xsi:type="StringAttributeDecoder" caseSensitive="false"/> </Attribute> <Attribute name="urn:oid:1.3.6.1.4.1.5923.1.1.1.5" id="primary-affiliation"> <AttributeDecoder xsi:type="StringAttributeDecoder" caseSensitive="false"/> </Attribute> <Attribute name="urn:mace:dir:attribute-def:eduPersonTargetedID" id="targeted-id"> <AttributeDecoder xsi:type="ScopedAttributeDecoder"/> <AttributeDecoder xsi:type="NameIDFromScopedAttributeDecoder" formatter="$NameQualifier!$SPNameQualifier!$Name" defaultQualifiers="true"/> </Attribute> -->
- ShibbolethSPを再起動する
# systemctl restart shibd
- openamの「Fadaration」画面を開く
- エンティティープロバイダでidpの設定を開く
- 「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の以下のパスに次のテストプログラムを配置する
# 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 #user_table # regexp .*
- 仮想ドメインの場合「/etc/sympa/ドメイン名」ディレクトリにauth.confをコピーすること
- httpdに上記SSOでアクセスした場合にShibbolethを使用する設定を追加
# vi /etc/httpd/conf.d/sympa.conf <Location /static-sympa> Require all granted ShibRequestSetting applicationId app-groupware </Location> <Location /sympa/sso_login/inqueue> <Location /sympa> AuthType shibboleth ShibRequestSetting requireSession 1 require shib-session </Location> </Location>
- httpdを再起動する
# systemctl restart httpd
- 下記アドレスにアクセスする
https://sp.example.com/sympa - 右上のログインボタンが認証設定で変更した「InQueue Federation」になっていること
- ボタンを押した際にOpenAMにリダイレクトすること
- ログイン後、右上のユーザ名がメールアドレスになっていること