PicketLinkを見てみる(3) Federation - IdPの設定について

3回目。Federationばかり見ているので、しばらくFederationを見ていくことにする。理由といえば、以下二つ。
・Federation周りなら多少知識があること
IDMに依存していない*1ようなので、単独で調べる事ができること
PicketLinkのFederationについて書くのが、誰得なのかよくわからんが、まあいいや。


とりあえずSAMLのスペックはこちら。 SAML Introduction | SAML XML.org
前に軽く見たけど使ってなかったので細部は忘れた。Identity Providerと、Service Providerの間では事前に信頼関係を結ぶ必要があるはずだが、多分、公開鍵を交換しておけばいいんじゃないかな?あとで、署名付きのサンプルが出てくるからそこで再度確認しよう。(と、思ったがpicketlink-idfed.xml要素が信頼関係にあたると思う。その上で鍵についてはあとで確認。)


前回書いたように、サンプルのJSPには重要なことはないので、設定ファイルを見ていく。今回のはUserGuide.pdfの丸写しに近い。ページ数が少ないドキュメントだから、原本にあたった方がよいかも。

IdP(idp.war)

web.xmlには、通常のForm認証を設定する。ロールとして、manager、Sales、Employeeを定義している。今回の例では、Salesロールが対象。

<!-- Define a Security Constraint on this Application -->
<security-constraint>
  <web-resource-collection>
    <web-resource-name>Manager command</web-resource-name>
    <url-pattern>/*</url-pattern>
  </web-resource-collection>
  <auth-constraint>
     <role-name>manager</role-name>
     <role-name>Sales</role-name>
     <role-name>Employee</role-name>
  </auth-constraint>
</security-constraint>
<!-- Define the Login Configuration for this Application -->
<login-config>
  <auth-method>FORM</auth-method>
  <realm-name>PicketLink IDP Application</realm-name>
  <form-login-config>
     <form-login-page>/jsp/login.jsp</form-login-page>
     <form-error-page>/jsp/login-error.jsp</form-error-page>
  </form-login-config>
</login-config>
<!-- Security roles referenced by this web application -->
<security-role>
  <role-name>manager</role-name>
</security-role>
<security-role>
  <role-name>Sales</role-name>
</security-role>
<security-role>
  <role-name>Employee</role-name>
</security-role>


context.xmlに、IDP用のValveをセット。上のIDPSAMLDebugValveはデバッグ用だな。なおcontext.xmlはMETA-INFとWEB-INF両方にあるが、META-INFのはTomcat用。WEB-INFのはJBoss用。

<Context>
    <Valve
        className="org.picketlink.identity.federation.bindings.tomcat.idp.IDPSAMLDebugValve" />
    <Valve
        className="org.picketlink.identity.federation.bindings.tomcat.idp.IDPWebBrowserSSOValve"
        signOutgoingMessages="false"
        ignoreIncomingSignatures="true"/>
</Context>


picketlink-idfed.xmlに、という要素が。ここでIdPを定義していて、要素で信頼できるSPを指定している…と思う。

<PicketLinkIDP xmlns="urn:picketlink:identity-federation:config:1.0" >
<IdentityURL>http://localhost:8080/idp/</IdentityURL>
<Trust>
   <Domains>localhost,jboss.com,jboss.org</Domains>
</Trust>
</PicketLinkIDP>


picketlink-handlers.xmlにハンドラを指定。SAML v.2プロトコルを実際に処理しているんだろう。

<Handlers xmlns="urn:picketlink:identity-federation:handler:config:1.0">
  <Handler class="org.picketlink.identity.federation.web.handlers.saml2.SAML2IssuerTrustHandler"/>
  <Handler class="org.picketlink.identity.federation.web.handlers.saml2.SAML2LogOutHandler"/>
  <Handler class="org.picketlink.identity.federation.web.handlers.saml2.SAML2AuthenticationHandler"/>
   <Handler class="org.picketlink.identity.federation.web.handlers.saml2.RolesGenerationHandler"/>
</Handlers>


実際のユーザとロールの設定は、users.propertiesroles.propertiesにあって、これを読み込んでいるのは、DefaultLoginHandler.javaDefaultRoleGenerator.javaみたいだな。
user.properties

tomcat=tomcat

roles.properties

tomcat=manager,sales,employee


ずいぶん長くなったので、今日はここまで。

TODO

SP
  • 設定ファイル確認
IdP
その他
  • ログを確認
  • 署名付きのサンプル確認

*1:試しに初回のサンプルでpicketlink-idm-1.1.5.CR01.jarを削除してみたが問題なく動作した。IdentityをDBやLDAPから取得する場合は、IDMを使うのが効率的だろう。