简体   繁体   English

LADP - Apache 上的 Kerberos 设置与 Wordpress 单点登录不起作用

[英]LADP - Kerberos Setup on Apache with Wordpress Single Sign-On not working

We had a local network setup with Active Directory.我们使用 Active Directory 进行了本地网络设置。 We developed a website which will be hosted and accessible only from the local network.我们开发了一个只能从本地网络托管和访问的网站。 If a user is already logged in to the Active Directory on the OS we would like to have the user automatically signed in on our Wordpress website as soon as they visit it.如果用户已经登录到操作系统上的 Active Directory,我们希望用户在访问我们的 Wordpress 网站时立即自动登录。

When following up documentations only we still where facing issues which we found it very difficult to fix and it took us a lot of time to have such a setup successfully woking.在仅跟踪文档时,我们仍然面临着我们发现很难修复的问题,我们花了很多时间才能成功启动这样的设置。 Some of the errors were:一些错误是:

  • gss_acquire_cred() failed: Unspecified GSS failure. gss_acquire_cred() 失败:未指定的 GSS 失败。 no key table entry found未找到关键表条目
  • failed to verify krb5 credentials: Key Version is not available无法验证 krb5 凭据:密钥版本不可用

The answer will be listing all the issues that we faced and how we managed to tackle them, in case some on faces the same problems when setting this up.答案将列出我们面临的所有问题以及我们如何设法解决这些问题,以防某些人在设置时遇到相同的问题。

Create Keytab file on the Active Directory Domain Controller在 Active Directory 域控制器上创建 Keytab 文件

  • This is something that we did not do ourselves but provided the command to an Active Directory expert in order to execute the below command.这是我们自己没有做的事情,而是将命令提供给 Active Directory 专家以执行以下命令。 This command is case sensitive, therefore it is very important that if the domain is in uppercase (as in example below), it is also executed with uppercase domain on the active directory.此命令区分大小写,因此非常重要的是,如果域是大写的(如下例所示),它也会在活动目录中使用大写域执行。
  • Command命令
    • ktpass -princ HTTP/intranet.domain.com@DOMAIN.COM -pass "{PASSWORD}" -mapuser username@DOMAIN.COM -Ptype KRB5_NT_PRINCIPAL -out website-auth.keytab
  • From the ktpass command:从 ktpass 命令:
    • intranet.domain.com - Was our wordpress website url intranet.domain.com - 是我们的 wordpress 网站 url
    • DOMAIN.COM - Is the Active directory domain DOMAIN.COM - 是活动目录域
    • {PASSWORD} - any random password eg UjhmPz5UPwx2VhQir7 {PASSWORD} - 任何随机密码,例如 UjhmPz5UPwx2VhQir7
      • Please note this is very important : since we had an issue with the passwords.请注意这非常重要:因为我们的密码有问题。 Once the ktpass is created, do not change the password for the related service user account in the active directory.创建 ktpass 后,请勿更改活动目录中相关服务用户帐户的密码。 Every time a service account password is changed through active directory the keytab version on active directory is also updated and you won't be able to authenticate unless you update the keytab file on apache as well.每次通过活动目录更改服务帐户密码时,活动目录上的密钥表版本也会更新,除非您也更新 apache 上的密钥表文件,否则您将无法进行身份验证。 Therefore if you change the password to a new one and then revert back to the old you would still have authentication issues (even though the password is now reverted back to original value).因此,如果您将密码更改为新密码,然后恢复为旧密码,您仍然会遇到身份验证问题(即使密码现在已恢复为原始值)。 More info here: https://support.oneidentity.com/fr-fr/kb/33866/when-does-the-vno-in-host-keytab-change-更多信息在这里: https : //support.oneidentity.com/fr-fr/kb/33866/when-does-the-vno-in-host-keytab-change-
    • username@DOMAIN.COM - service account of the Active Directory username@DOMAIN.COM - Active Directory 的服务帐户
      • The account password should have a password set to Not Expired.帐户密码应将密码设置为“未过期”。
      • The account should be trusted for delegation.应该信任该帐户进行委派。
    • website-auth.keytab - the filename of the generated keytab. website-auth.keytab - 生成的密钥表的文件名。 we stored it at /etc/httpd/kerberos-credentials/website-auth.keytab我们将它存储在/etc/httpd/kerberos-credentials/website-auth.keytab
  • Copy the Keytab file from AD Domain Controller to the web server hosted on Apache.将 Keytab 文件从 AD 域控制器复制到托管在 Apache 上的 Web 服务器。

Install Kerberos Client Libraries On The Web Server:在 Web 服务器上安装 Kerberos 客户端库:

  • sudo apt-get install krb5-user (Ubuntu) sudo apt-get install krb5-user (Ubuntu)
  • yum install krb5-workstation krb5-libs krb5-auth-dialog (Centos) yum 安装 krb5-workstation krb5-libs krb5-auth-dialog (Centos)

Configure the Active Directory domain in the Kerberos Configuration file在 Kerberos 配置文件中配置 Active Directory 域

  • Update the /etc/krb5.conf更新 /etc/krb5.conf
  • I am pasting our config file template below.我正在下面粘贴我们的配置文件模板。 It was very important for us to update the enctypes parameters since the default config file did not include the enctype of the keytab generated from active directory and it was causing issues with authentication.更新 enctypes 参数对我们来说非常重要,因为默认配置文件不包含从活动目录生成的密钥表的 enctype,这会导致身份验证问题。 In this sample I am including all the enctypes that I managed to find from my research.在这个示例中,我包含了我从研究中找到的所有加密类型。
# Configuration snippets may be placed in this directory as well
includedir /etc/krb5.conf.d/

[logging]
 default = FILE:/var/log/krb5libs.log
 kdc = FILE:/var/log/krb5kdc.log
 admin_server = FILE:/var/log/kadmind.log

[libdefaults]
 dns_lookup_realm = true
 dns_lookup_kdc = true
 ticket_lifetime = 24h
 renew_lifetime = 7d
 forwardable = true
 rdns = false
 pkinit_anchors = /etc/pki/tls/certs/ca-bundle.crt
 default_realm = DOMAIN.COM
 default_tkt_enctypes = aes256-cts des3-cbc-sha1 arcfour-hmac des-cbc-crc aes256-cts-hmac-sha1-96 des-cbc-md5 arcfour-hmac-md5
 default_tgs_enctypes = aes256-cts des3-cbc-sha1 arcfour-hmac des-cbc-crc aes256-cts-hmac-sha1-96 des-cbc-md5 arcfour-hmac-md5
 permitted_enctypes = aes256-cts des3-cbc-sha1 arcfour-hmac des-cbc-crc aes256-cts-hmac-sha1-96 des-cbc-md5 arcfour-hmac-md5

[realms]
 DOMAIN.COM = {
   admin_server = DOMAIN.COM
   kdc = DOMAIN.COM
 }

[domain_realm]
 domain.com = DOMAIN.COM
 .domain.com = DOMAIN.COM

[login]
 krb4_convert = true
 krb4_get_tickets = true

Install the auth_kerb module for Apache为 Apache 安装 auth_kerb 模块

  • Ubuntu: Ubuntu:
    • sudo apt-get install libapache2-mod-auth-kerb须藤 apt-get 安装 libapache2-mod-auth-kerb
    • a2enmod auth_kerb a2enmod auth_kerb
    • Restart apache重启apache
  • Centos: Centos:
    • yum install mod_auth_kerb yum 安装 mod_auth_kerb
    • Restart apache: systemctl restart apache2重启apache:systemctl restart apache2

Configure Kerberos SSO for the site directory为站点目录配置 Kerberos SSO

  • Ubuntu: Edit the /etc/apache2/sites-enabled/000-default.conf file Ubuntu:编辑 /etc/apache2/sites-enabled/000-default.conf 文件
  • Centos: Edit the auth_kerb.conf configuration file in the /etc/httpd/conf.d/ folder Centos:编辑/etc/httpd/conf.d/文件夹下的auth_kerb.conf配置文件
  • We were working on Centos, so I do not have the exact configuration for Ubuntu but it should be quite similar to the Centos config.我们在 Centos 上工作,所以我没有 Ubuntu 的确切配置,但它应该与 Centos 配置非常相似。 A template of our configuration file is:我们的配置文件的模板是:
  • After setting the configuration file, apache needs to be restarted once again设置好配置文件后,需要再次重启apache
LoadModule auth_kerb_module /usr/lib64/httpd/modules/mod_auth_kerb.so

<Directory "/var/www/html">
Order allow,deny
Allow from all

AuthType Kerberos
AuthName "username used in keytab"
KrbAuthRealms DOMAIN.COM
KrbServiceName HTTP/intranet.domain.com@DOMAIN.COM
Krb5Keytab /etc/httpd/kerberos-credentials/website-auth.keytab
KrbMethodNegotiate On
KrbMethodK5Passwd On
KrbVerifyKDC On
require valid-user
</Directory>

Check httpd_can_network_connect on apache在 apache 上检查 httpd_can_network_connect

  • After the above setup we thought we were ready but still could not have the authentication work from the website.完成上述设置后,我们认为我们已准备就绪,但仍然无法从网站进行身份验证。
  • After some research we noticed that we need to enable the httpd_can_network_connect setting on he apache server.经过一些研究,我们注意到我们需要在 apache 服务器上启用httpd_can_network_connect设置。 To do so run:为此,请运行:
    • getsebool -a | grep httpd getsebool -a | grep httpd : it was returning httpd_can_network_connect --> off getsebool -a | grep httpd :它正在返回 httpd_can_network_connect --> off
    • setsebool -P httpd_can_network_connect on : Enabled the setting setsebool -P httpd_can_network_connect on : 启用设置
    • Restart apache service重启apache服务
    • Information fetched from LDAP works with PHP CLI but not through apacheLDAP获取的信息适用于 PHP CLI,但不适用于 apache

Add wordpress website to local intranet on OS将 wordpress 网站添加到 OS 上的本地内网

  • To integrate Wordpress with kerberos we used a ready made premium plugin, but unfortunately not everything worked as smooth as we thought.为了将 Wordpress 与 kerberos 集成,我们使用了现成的高级插件,但不幸的是,并非一切都像我们想象的那样顺利。 With the above setup, when we were trying to access our wordpress website, the browser was popping up a default authentication dialog box.通过上述设置,当我们尝试访问我们的 wordpress 网站时,浏览器会弹出一个默认的身份验证对话框。 This was not the desired result since we wanted to have the user automatically logged in if they are logged in on the Active Directory.这不是预期的结果,因为我们希望用户在登录 Active Directory 时自动登录。 This was being caused because the windows machine we were testing on did not have our wordpress website listed in the Local Intranets configuration.这是因为我们正在测试的 Windows 机器没有在本地 Intranet 配置中列出我们的 wordpress 网站。 To add a website to the local intranet:将网站添加到本地 Intranet:
    • Go to Control Panel进入控制面板
    • Go to Internet Options转到 Internet 选项
    • Click on the Security tab单击安全选项卡
    • Click on the Local Intranet icon单击本地 Intranet 图标
    • Click on Sites单击站点
    • Click on Advanced button点击高级按钮
    • Add the Wordpres site url添加 Wordpres 站点 url

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM