LoginSignup
13
19

More than 5 years have passed since last update.

ApacheでActive Directory SSO

Posted at

本記事の内容

CentOS/Apache上のリソースにアクセス制限を行い、Active Directoryで認証させる方法です。ADにログオンしているWindows端末からはKerberosでSSOできるようにします。

参考文献

これがわかりやすいです。
https://active-directory-wp.com/docs/Networking/Single_Sign_On/Kerberos_SSO_with_Apache_on_Linux.html

Active Directoryの設定

  • ドメインコントローラがなければセットアップします (本記事ではhishi.localドメインで、DCはdc1.hishi.localです)
  • apacheユーザーをドメインユーザーとして作成します (Linuxからの接続に利用します)
  • keytabファイルを生成します
C:\> ktpass.exe -princ HTTP/www.hishi.local@HISHI.LOCAL -mapuser apache@hishi.local -pass Password1 -crypto RC4-HMAC-NT -ptype KRB5_NT_PRINCIPAL -out .\kerberos.keytab

このコマンドの詳細は、ここを参照してください。

CentOSでの設定

  • Apacheが入ってなければ入れてください。 # yum install -y httpd
  • Kerberos認証モジュールをインストールします # yum install -y mod_auth_kerb
  • 確認用のコマンドをインストールします # yum install -y krb5-workstation.x86_64
  • ADで生成したkeytabファイルを /etc にコピーし、パーミッションを設定します
# chown apache:apache kerberos.keytab
# chmod 400 kerberos.keytab
  • /etc/krb5.conf を編集します。
[logging]
(省略)

[libdefaults]
(省略)
 default_realm = HISHI.LOCAL
(省略)

[realms]
HISHI.LOCAL = {
  kdc = dc1.hishi.local
  admin_server = dc1.hishi.local
  default_domain = hishi.local
}

[domain_realm]
.hishi.local = HISHI.LOCAL
hishi.local = HISHI.LOCAL

  • dc1.hishi.local を解決できるようhostsなりresolve.confなり修正します
  • httpd.confを編集します
<Directory "/var/www/html/sso">
    AuthType Kerberos
    AuthName "Kerberos Auth"
    KrbAuthRealms HISHI.LOCAL
    KrbServiceName HTTP/www.hishi.local
    Krb5Keytab /etc/kerberos.keytab
    KrbMethodNegotiate On
    KrbMethodK5Passwd On
    require valid-user
</Directory>
  • 試しにticketをとってみます kinit -p apache@HISHI.LOCAL

Internet Explorerから接続

すべての設定が完了ましたので、Windows端末でInternet Explorerで接続します。ドメインにログオンした端末からはSSOできますし、そうでない端末はドメインのuser/passwordでログインできます。
この際、Apacheがイントラネットゾーン(正確にはゾーンの設定ではなくセキュリティの設定ですが)として認識しないとSSOできませんので、必要に応じてインターネットオプションを設定します。

13
19
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
19