前説
個人的には全く好きではないのだが、一部界隈では圧倒的な存在感を持っているShibboleth。このShibboleth IdPをCASサーバとしても利用できるように設定する。
CASで利用できるようにする理由
Shibbolethの特徴はIdPとSPで相互に信頼関係を築くことと、eduPersonXXXの形式で多くの属性を渡すことができることにある。しかしながらIdPとSPで相互にメタデータの作成と交換という作業が必要になってくる。
例えばShibboleth IdPの認証機能を組織内で簡易に利用したいというようなニーズがあったとすると、Shibbolethは使いにくい。CASを有効にしておくことで、利用者には通常のShibboleth IdPで認証を行わせながら、CASサーバとしても利用することができる。
CASサーバとして利用する場合のデメリットとしては、ユーザIDしかSPに渡すことができない点が大きい。そのため特定の属性値(eduPersonAffiliationがfacultyなど)を持つユーザにだけ利用させたいというようなことがIdPの認証結果だけではできない。
設定方法
Shibboleth IdP側の設定
Shibboleth 3.4.6の場合、以下のファイルを編集する。
- #idp.cas.StorageService=shibboleth.StorageService
+ idp.cas.StorageService=shibboleth.StorageService
<bean id="shibboleth.DefaultRelyingParty" parent="RelyingParty">
<property name="profileConfigurations">
<list>
...
+ <ref bean="CAS.LoginConfiguration" />
+ <ref bean="CAS.ProxyConfiguration" />
+ <ref bean="CAS.ValidateConfiguration" />
</list>
<bean id="reloadableServiceRegistry"
class="%{idp.cas.serviceRegistryClass:net.shibboleth.idp.cas.service.PatternServiceRegistry}">
<property name="definitions">
<list>
<!--
<bean class="net.shibboleth.idp.cas.service.ServiceDefinition"
c:regex="https://([A-Za-z0-9_-]+\.)*example\.org(:\d+)?/.*"
p:group="proxying-services"
p:authorizedToProxy="true"
p:singleLogoutParticipant="true" />
+ -->
<bean class="net.shibboleth.idp.cas.service.ServiceDefinition"
- c:regex="http://([A-Za-z0-9_-]+\.)*example\.org(:\d+)?/.*"
+ c:regex="https?://([A-Za-z0-9_-]+\.)*hoge\.fuga(:\d+)?/.*"
p:group="non-proxying-services"
- p:authorizedToProxy="false" /
+ p:authorizedToProxy="false" />
- -->
</list>
</property>
</bean>
最後のconf/cas-protocol.xmlでCASサーバ機能の利用を許可するホスト名を指定できるため、自組織のドメインなどに書き換える。
設定変更後はTomcatを再起動して変更を反映させる。
SP側の設定
今回はお手軽にウェブサイトでのBASIC認証の置き換えを想定した設定とする。CentOS以外の場合は適宜読み替え。
なお、CASの仕様上SSLサーバ証明書が導入済みの必要がある。
ApacheのCAS認証用モジュールを追加する。
# yum install epel-release
# yum install mod_auth_cas
mod_auth_casインストール時に追加された設定ファイルをShibboleth IdPのものに書き換え、Apacheを再起動する。
- CASLoginURL https://login.example.org/cas/login
+ CASLoginURL https://shibboleth-idp.hoge.fuga/idp/profile/cas/login
- CASValidateURL https://login.example.org/cas/serviceValidate
+ CASValidateURL https://shibboleth-idp.hoge.fuga/idp/profile/cas/serviceValidate
認証を設定したいディレクトリにあった.htaccessのBASIC認証部分を書き換える。
Authtype CAS
Require valid-user