Continuum の認証を LDAP で行う
最近はどうやら Hudson がアツイようで、少し気をひかれている所もあるのですが、Continuum のネタを備忘録も兼ねて。
ここにもあるとおり、Continuum 1.1 からは LDAP を認証のバックエンドに利用出来るようになっています。(ただし READ-only) ちなみに、認証のバックエンドにはIntroduction が採択されている模様です。
ざっくりと環境は以下の通り。
continuum が通常通り利用出来る状態でインストールされている事が前提です。Tomcat 6.0 での設定はApache Maven Continuum - Guide to Install Continuum on Tomcatを参考に。
基本的にはガイド通りに作業します。
<component> <role>org.codehaus.plexus.redback.common.ldap.connection.LdapConnectionFactory</role> <role-hint>configurable</role-hint> <implementation>org.codehaus.plexus.redback.common.ldap.connection.ConfigurableLdapConnectionFactory</implementation> <description></description> <configuration> <hostname>X.X.X.X</hostname> <port>389</port> <baseDn>dc=example,dc=com</baseDn> <contextFactory>com.sun.jndi.ldap.LdapCtxFactory</contextFactory> <password>XXXX</password> <bindDn>cn=admin,dc=example,dc=com</bindDn> </configuration> </component> : <component> <role>org.codehaus.plexus.redback.common.ldap.UserMapper</role> <role-hint>ldap</role-hint> <implementation>org.codehaus.plexus.redback.common.ldap.LdapUserMapper</implementation> <description></description> <configuration> <email-attribute>mail</email-attribute> <full-name-attribute>gecos</full-name-attribute> <password-attribute>userPassword</password-attribute> <user-id-attribute>uid</user-id-attribute> <user-base-dn>ou=Users,dc=example,dc=com</user-base-dn> <user-object-class>inetOrgPerson</user-object-class> </configuration> </component> : <component> <role>org.codehaus.plexus.redback.users.UserManager</role> <role-hint>cached</role-hint> <implementation>org.codehaus.plexus.redback.users.cached.CachedUserManager</implementation> <description>CachedUserManager</description> <requirements> <requirement> <role>org.codehaus.plexus.redback.users.UserManager</role> <role-hint>ldap</role-hint> <field-name>userImpl</field-name> </requirement> <requirement> <role>org.codehaus.plexus.ehcache.EhcacheComponent</role> <role-hint>users</role-hint> <field-name>usersCache</field-name> </requirement> </requirements> </component>
- security.properties を設置する。場所はここで設定した ${appserver.base}/conf 以下です。
user.manager.impl=ldap ldap.bind.authenticator.enabled=true redback.default.admin=XXXX redback.default.guest=nobody security.policy.password.expiration.enabled=false user.manager.impl=cached
各々の設定の詳細はLdap Integrationにあります。認証方式ですが、ユーザ毎でバインド出来るかで認証するよう、ldap.bind.authenticator.enabled は true にしてあります。おそらく通常はそれで十分なような気がします。
continuum 側は基本的にこれだけです。幾つか注意点としてあるのが、
- LdapConnectionFactory で指定してある baseDn は、LdapUserMapper の user-base-dn の後ろには append されないので、user-base-dn でも再度 baseDn は指定する
- LdapUserMapper では属性を指定しないと NPE が発生する。その為の対処は後述
- security.properties の置き場所は、先述の通り ${appserver.base} で指定した場所に conf を作り、その下に置く。
- security.properties での guest と admin は適当に設定してはまずい
といった所でしょうか。
三つ目ですが、smbldap-tools を利用していると、デフォルトでは mail 属性はつかないので、以下のように属性に mail を設定しておきます。
$ cat ldapmodify.txt dn: uid=xxx,ou=Users,dc=example,dc=com changetype: modify add: mail mail: xxx@example.com $ ldapmodify -x -h localhost -D 'cn=admin,dc=example,dc=com' -W -f ldapmodify.txt
また、guest と admin ですが、既存のアカウントの中で適宜選んでおけばよいので、今回は guest は nobody に、admin には適当なアカウントを設定しておきます。尚、admin のアカウントが LDAP 側に無い場合には、admin アカウントを作成しようとする画面に遷移し、実際に作成しようとすると、READ-only な為エラーが発生します。guest アカウントが無い場合には、そもそもの初回アクセスでエラーが発生します。
ちなみにそれ以外ではまったのですが、Tomcat のコンテキストで unpackWar を false にしていると、毎回 application.xml が上書きされてしまいます。今回は unpackWar を外しました。。。