5.2. mod_auth_kerb の例
本セクションでは、Red Hat Enterprise Linux で JBoss Core Services の Apache HTTP Server および mod_auth_kerb で Kerberos 認証を設定する基本的な手順を説明します。
5.2.1. mod_auth_kerb 例の要件
以下は、作業例の要件の一覧です。手順例を使用する前に、すべての要件を満たしていることを確認してください。
- GSS がネゴシエートされたサポートで curl をインストールします (設定のテスト用)。
- JBoss Core Services と同じホストで Kerberos または LDAP サーバー (ApacheDS など) を設定し、実行します。
LDAP サーバーを使用する場合は、以下の LDAP ユーザーを作成します。
ユーザー
krbtgt
を作成します。dn: uid=krbtgt,ou=Users,dc=example,dc=com objectClass: top objectClass: person objectClass: inetOrgPerson objectClass: krb5principal objectClass: krb5kdcentry cn: KDC Service sn: Service uid: krbtgt userPassword: secret krb5PrincipalName: krbtgt/EXAMPLE.COM@EXAMPLE.COM krb5KeyVersionNumber: 0
ユーザー
ldap
を作成します。dn: uid=ldap,ou=Users,dc=example,dc=com objectClass: top objectClass: person objectClass: inetOrgPerson objectClass: krb5principal objectClass: krb5kdcentry cn: LDAP sn: Service uid: ldap userPassword: randall krb5PrincipalName: ldap/localhost@EXAMPLE.COM krb5KeyVersionNumber: 0
ユーザー
HTTP
を作成します。dn: uid=HTTP,ou=Users,dc=example,dc=com objectClass: top objectClass: person objectClass: inetOrgPerson objectClass: krb5principal objectClass: krb5kdcentry cn: HTTP sn: Service uid: HTTP userPassword: secretpwd krb5PrincipalName: HTTP/localhost@EXAMPLE.COM krb5KeyVersionNumber: 0
ユーザー
hnelson
(テストユーザー) を作成します。dn: uid=hnelson,ou=Users,dc=example,dc=com objectClass: top objectClass: person objectClass: inetOrgPerson objectClass: krb5principal objectClass: krb5kdcentry cn: Horatio Nelson sn: Nelson uid: hnelson userPassword: secret krb5PrincipalName: hnelson@EXAMPLE.COM krb5KeyVersionNumber: 0
5.2.2. Kerberos クライアントの設定
/etc
ディレクトリーにkrb5.conf
設定ファイルを作成し、以下をファイルに追加します。[logging] default = FILE:/var/log/krb5libs.log kdc = FILE:/var/log/krb5kdc.log admin_server = FILE:/var/log/kadmind.log [libdefaults] default_realm = EXAMPLE.COM default_tgs_enctypes = des-cbc-md5,des3-cbc-sha1-kd default_tkt_enctypes = des-cbc-md5,des3-cbc-sha1-kd dns_lookup_realm = false dns_lookup_kdc = false allow_weak_crypto = yes ticket_lifetime = 24h renew_lifetime = 7d forwardable = yes [realms] EXAMPLE.COM = { kdc = localhost:60088 admin_server = localhost:60088 } [domain_realm] .example.com = EXAMPLE.COM example.com = EXAMPLE.COM
JBCS_HOME/httpd/conf
フォルダーに以下の内容が含まれるキータブを作成します。# ktutil ktutil: addent -password -p HTTP/localhost@EXAMPLE.COM -k 0 -e des-cbc-md5 Password for HTTP/localhost@EXAMPLE.COM: secretpwd ktutil: list slot KVNO Principal ---- ---- --------------------------------------------------------------------- 1 0 HTTP/localhost@EXAMPLE.COM ktutil: wkt JBCS_HOME/httpd/conf/krb5.keytab ktutil: quit
環境変数は ktutil プロンプト内では拡張されません。ユーザーは JBCS_HOME 変数の完全パスを置き換える必要があります。
root ユーザーとして以下のコマンドを実行し、正しいグループとパーミッションをキータブに適用します。
# chgrp apache JBCS_HOME/httpd/conf/krb5.keytab # chmod 640 JBCS_HOME/httpd/conf/krb5.keytab
以下のホスト設定が
/etc/hosts
ファイルに含まれるようにします。127.0.0.1 localhost
5.2.3. mod_auth_kerb の設定
JBCS_HOME/httpd/conf.d/
フォルダーに auth_kerb.conf
設定ファイルを作成し、以下の設定をファイルに追加します。
# # The mod_auth_kerb module implements Kerberos authentication over HTTP, following the "Negotiate" protocol. # # The LoadModule statement is done in conf.d/10-auth_kerb.conf # LoadModule auth_kerb_module modules/mod_auth_kerb.so <Location /kerberostest> AuthType Kerberos AuthName "Kerberos Login" KrbMethodNegotiate On KrbMethodK5Passwd Off KrbAuthRealms EXAMPLE.COM KrbServiceName HTTP Krb5KeyTab $JBCS_HOME/httpd/krb5.keytab require valid-user </Location>
環境変数は、設定ファイル内で拡張されません。ユーザーは JBCS_HOME 変数の完全パスを置き換える必要があります。
5.2.4. Kerberos 認証のテスト
-
auth_kerb_page.html
というテストページをJBCS_HOME/httpd/www/html/kerberostest/
に作成します。 以下のコンテンツをテストページ (
auth_kerb_page.html
) に追加します。<html> <body> <h1>mod_auth_kerb successfully authenticated!</h1> </body> </html>
-
任意: デバッグのログレベルを
JBCS_HOME/httpd/conf/httpd.conf
に設定します。 - Apache HTTP Server を開始します。詳細は 『インストールガイド』 を参照してください。
以下のように認証をテストします。
test ユーザー
hnelson
の Kerberos 認証を開始します。$ kinit hnelson
test ユーザー
hnelson
の詳細を表示します。$ klist
以下のような結果が表示されます。
Ticket cache: FILE:/tmp/krb5cc_18602 Default principal: hnelson@EXAMPLE.COM Valid starting Expires Service principal 06/03/13 14:21:13 06/04/13 14:21:13 krbtgt/EXAMPLE.COM@EXAMPLE.COM renew until 06/10/13 14:21:13
以下のように Apache HTTP Server Kerberos 認証をテストします。
$ curl --negotiate -u : http://localhost/kerberostest/auth_kerb_page.html
正常に機能している場合は、以下の結果が表示されます。
<html> <body> <h1>mod_auth_kerb successfully authenticated!</h1> </body> </html>
mod_auth_kerb の詳細は、http://modauthkerb.sourceforge.net/ を参照してください。