IIS に Shibboleth SP をインストールする
2021-05-25 - 相本 智仁
はじめに
IIS に Shibboleth SP をインストールする手順を紹介します。
IIS 上に環境変数を表示するコンテンツを準備して、 Shibboleth SP でそのコンテンツを保護対象とします。 IdP で認証完了したらコンテンツにアクセス可能となり、 IdP から受け取った値を表示することを実現します。
環境および前提事項
- Windows 2019 Server の IIS を使用
- IIS はインストール済みで HTTPS でアクセス出来るようにしておきます。
- 「役割の追加」で「アプリケーション開発」の 「.NET」 を選択しておきます。
- この記事では https://win2019.example.co.jp/ で IIS にアクセス出来る構成です。
- 自分の環境で実施する際は win2019.example.co.jp を読み替えて実施ください。
- Shibboleth SP V3 を使用
- SAML の IdP は構築済み
- Shibboleth SPと連携する SAML IdP は構築済みとします。
- この記事では OpenAM を SAML IdP とします。
事前準備
事前準備として環境変数を表示するコンテンツを準備します。
secureフォルダにファイルを作成
IIS のドキュメントルート直下に secure というフォルダを作成し、 ディレクトリ内にenv.aspxという名前のファイルを作成します。

ファイルの中身は以下のようにします。
<% @ Page Language="C#" %>
<html><body>
<%
Response.Write("<h3>Server Variables</h3>");
foreach (string var in Request.ServerVariables)
{
Response.Write(var + " = " + Request[var] + "<br>");
}
%>
</body></html>
アクセス確認
ファイルを作成したらブラウザからアクセスします。
- https://win2019.example.co.jp/secure/env.aspx
ブラウザ上に環境変数の一覧が表示されることを確認します。 このコンテンツを Shibboleth SP で保護します。

Shibboleth SPインストール
Shibboleth SP の入手
Shibboleth公式ダウンロードから最新版をダウンロードします。 「latest」「win64」と辿るとWindows版SPのインストーラーのファイルが確認できます。

msiファイルをダウンロードします。 本記事では執筆時の最新版shibboleth-sp-3.2.2.0-win64.msi を使います。
Shibboleth SP インストーラーの実行
ダウンロードしたshibboleth-sp-3.2.2.0-win64.msiを実行します。
インストールウィザード開始
実行するとインストールウィザードが開始されます。「Next」を押します。

ライセンスの表示
ライセンスを確認しAgreementにチェックを入れ「Next」を押します。

Shibboleth設定場所
Shibbolethの設定ファイルなどのインストール先です。デフォルトのままとします。
「Configure IIS support」というチェックボックスがあります。

「Configure IIS support」にチェックを入れて「Next」を押します。

インストール確認
インストールの最終確認です。「Install」を押します。

インストールが実行されるためしばらく待ちます。
インストールの完了
インストールが完了すると下記のウイザードが表示されます。「Finish」を押します。

Windows Serverの再起動
Shibboleth SP のセットアップのために OS の再起動が必要です。 再起動するか確認のウィンドウが表示されるため「Yes」を押して、Windows Server を再起動します。

以上で Shibboleth SP のインストール作業は終了です。
Shibboleth SP の設定
インストールが完了したら Shibboleth SP の設定作業を行います。
IdP メタデータの配置
IdP からメタデータを入手し、Shibboleth SP の設定ディレクトリに配置します。 Shibboleth SP の設定ディレクトリはインストール時に指定しており「C:\opt\shibboleth-sp\etc\shibboleth」です。
本記事ではopenam_saml_meta.xml
というファイル名で配置しました。
shibboleth2.xml の変更
C:\opt\shibboleth-sp\etc\shibboleth\shibboleth2.xml を変更します。変更点は次のとおりです。
- サイトIDの確認(IISとShibboleth SPの設定が異なっている場合は合わせる)
- サーバーのホスト名を設定
- SP の EntityID を設定
- IdP のEntityID を設定
- IdP のメタデータを設定
サイトIDの確認
ツールから「インターネットインフォメーサービス(IIS)マネージャー」を起動し、 IISのサイトのIDを確認します。

shibboleth2.xmlの<InProcess>
にあるサイトの設定のid
と一致していることを確認します。
(一致していなければ合わせます。)
<Site id="1" name="sp.example.org"/>
サーバーのホスト名を設定
設定箇所はデフォルトではsp.example.com
となっている所を変更します。
<InProcess>
と<RequestMap>
の2箇所です。
<Site id="1" name="win2019.example.co.jp"/>
と
<Host name="win2019.example.co.jp">
SP の EntityID を設定
デフォルトではEntityIDはhttps://sp.example.org/shibboleth
となっています。
EntityIDは他のサービスと重ならないユニークな値とする必要が有るため、サーバーのFQDNを利用することが多いです。
本記事では以下のようにします。
<ApplicationDefaults entityID="https://win2019.example.co.jp/shibboleth"
IdP の EntityID を設定
デフォルトではEntityIDはhttps://idp.example.org/idp/shibboleth
となっています。
IdP のメタデータに記載されているEntityIDに変更します。
<ApplicationDefaults entityID="https://ubuntu-openam.example.co.jp:8443/openam"
IdP の メタデータを設定
配置したIdPのメタデータを読み込む設定を行います。 以下の設定を追加します。
<MetadataProvider type="XML" validate="true" path="openam_saml_meta.xml"/>
以上で設定変更は完了です。
最後に参考情報として、インストール直後のshibboleth2.xmlとの比較(diffの結果)です。
# diff -u shibboleth2.xml.org shibboleth2.xml
--- shibboleth2.xml.org 2020-12-10 17:16:52.000000000 +0900
+++ shibboleth2.xml 2021-05-25 16:03:13.235375012 +0900
@@ -15,7 +15,7 @@
required so that the proper <Host> in the request map above is found without
having to cover every possible DNS/IP combination the user might enter.
-->
- <Site id="1" name="sp.example.org"/>
+ <Site id="1" name="win2019.example.co.jp"/>
<!--
When the port and scheme are omitted, the HTTP request's port and scheme are used.
If these are wrong because of virtualization, they can be explicitly set here to
@@ -44,7 +44,7 @@
https on the default ports. Note that the name and port in the <Host> elements MUST match
Apache's ServerName and Port directives or the IIS Site name in the <ISAPI> element above.
-->
- <Host name="sp.example.org">
+ <Host name="win2019.example.co.jp">
<Path name="secure" authType="shibboleth" requireSession="true"/>
</Host>
<!-- Example of a second vhost mapped to a different applicationId. -->
@@ -59,7 +59,7 @@
With IIS, resource requests are mapped by the RequestMapper to an applicationId that
points into to this section (or to the defaults here).
-->
- <ApplicationDefaults entityID="https://sp.example.org/shibboleth"
+ <ApplicationDefaults entityID="https://win2019.example.co.jp/shibboleth"
REMOTE_USER="eppn subject-id pairwise-id persistent-id"
cipherSuites="DEFAULT:!EXP:!LOW:!aNULL:!eNULL:!DES:!IDEA:!SEED:!RC4:!3DES:!kRSA:!SSLv2:!SSLv3:!TLSv1:!TLSv1.1">
@@ -80,7 +80,7 @@
entityID property and adjust discoveryURL to point to discovery service.
You can also override entityID on /Login query string, or in RequestMap/htaccess.
-->
- <SSO entityID="https://idp.example.org/idp/shibboleth"
+ <SSO entityID="https://ubuntu-openam.example.co.jp:8443/openam"
discoveryProtocol="SAMLDS" discoveryURL="https://ds.example.org/DS/WAYF">
SAML2
</SSO>
@@ -117,6 +117,7 @@
<!--
<MetadataProvider type="XML" validate="true" path="partner-metadata.xml"/>
-->
+ <MetadataProvider type="XML" validate="true" path="openam_saml_meta.xml"/>
<!-- Example of remotely supplied batch of signed metadata. -->
<!--
Shibboleth SP Service と IIS の再起動
Shibboleth SPは、「Shibboleth SP Service」と「IIS」の2つのサービスで動作しています。 設定変更したら、反映させるためにサービスを再起動します。
Shibboleth SP Service の再起動
「スタート」 -> 「Windows管理ツール」 -> 「サービス」を開きます。
その中にShibboleth Daemon(Default)
をクリックして「サービスの再起動」を行います。

IIS の再起動
「インターネットインフォメーサービス(IIS)マネージャー」から再起動を行います。
Shibboleth SP のメタデータ取得
設定が完了するとShibboleth SPのメタデータをダウンロード出来ます。 下記のURLからSPのメタデータをダウンロードし、IdPに登録します。
- https://win2019.example.co.jp/Shibboleth.sso/Metadata
動作確認
IdP への登録が終われば、連携完了です。 最初に動作確認したら環境変数を表示するコンテンツにアクセスします。
- https://win2019.example.co.jp/secure/env.aspx
今回はアクセスしてもコンテンツは表示されず、IdPのログイン画面が表示されます。 (下記はIdPであるOpenAMのログイン画面)

IdPでログインを完了すると環境変数の画面が表示されます。

Shibboleth SP インストール前と違い、Shibboleth SPがセットしたShib-
で始まる名称の環境変数が存在することが確認できます。
属性の受取り
ここまでで、IIS に Shibboleth SP をインストールして、IdPで認証後にコンテンツを表示させることが出来ました。 最後に IdP から属性を送って、それを環境変数で表示させることをやってみます。
SP の属性受取り設定
Shibboleth SP の属性マップの設定を行います。 C:\opt\shibboleth-sp\etc\shibboleth\attribute-map.xml を変更します。 変更点はコメントアウトされている下記の設定を有効にします。
<Attribute name="urn:oid:0.9.2342.19200300.100.1.1" id="uid"/>
この設定を行うとSAMLで送られてきた属性urn:oid:0.9.2342.19200300.100.1.1
が環境変数uidにセットされます。
設定変更したら再起動を忘れずに行います。
IdP の属性送信設定
IdP側でSAMLの属性でurn:oid:0.9.2342.19200300.100.1.1
という名前で値を送る設定を行います。
ここの作業は連携するIdPによります。 今回はOpenAMで行ったので「連携」->「https://win2019.example.co.jp/shibbolethSP」-> 「表明処理」->「属性マップ」で uid を送る設定を行います。

動作確認
設定が完了したら環境変数を表示するコンテンツにアクセスします。
- https://win2019.example.co.jp/secure/env.aspx
IdPでログインを完了すると環境変数の画面が表示されます。 先程と違い、環境変数uidがセットされていれば成功です。
