klemenb / simplesamlphp-module-negotiateserver
一个用于通过 Apache/IIS 集成 HTTP Negotiate 支持进行用户身份验证的 SimpleSAMLphp 模块。
Requires
This package is not auto-updated.
Last update: 2024-09-14 19:31:10 UTC
README
此 SimpleSAMLphp 模块允许用户通过 Apache/IIS 集成的 "HTTP Negotiate" 支持进行身份验证。它基本上基于原始的 "negotiate" 模块,但没有 php_krb5 依赖。所有身份验证(Kerberos/NTLM)处理都由 Web 服务器完成。
negotiateserver:Negotiate
: 通过 Apache/IIS 集成的 "HTTP Negotiate" 身份验证进行用户身份验证
negotiateserver:Negotiate
此扩展的主要目标是使用您的 Kerberos 会话自动检索相应的 SAML 会话。一个常见的用例是允许加入域的工作站网络无缝登录使用 SAML 进行身份验证的 Web 服务。当访问这些 Web 服务时,登录到工作站的域用户不会提示输入凭据。
托管 SimpleSAMLphp 的服务器的基本要求
- Apache 2.4 带有 mod_auth_kerb 或 IIS 7.0+(Web 服务器应加入域)
- SimpleSAMLphp 1.14.x 或更高版本
注意:此模块已在 Microsoft Active Directory 和运行在 Windows Server 2012 R2 上的 IIS 8.5 以及运行在 CentOS 7 上的 Apache 2.4 的环境中进行过测试。可能存在不同组合和/或服务器版本的问题,但一切也应正常工作在 2008 年以后的 Windows Server 上以及至少具有 Apache 2.2 的 Linux 发行版。
安装
可以通过 composer 安装此模块
composer require klemenb/simplesamlphp-module-negotiateserver:dev-master
由于我们依赖于 Web 服务器对 "HTTP Negotiate" 身份验证的处理,我们必须手动将配置文件添加到您的 SimpleSAMLphp 的 www 文件夹或正确编辑我们的虚拟主机定义。
Apache 配置
将以下 <Location> 指令添加到您的 VirtualHost 定义中
<Location "/module.php/negotiateserver/auth.php"> AuthName "[MY_ORGANIZATION_NAME] Authentication" AuthType Kerberos Krb5Keytab /etc/httpd/conf/HTTP.idp.keytab KrbMethodNegotiate On KrbMethodK5Passwd On require valid-user </Location>
请确保正确更新到您的 Kerberos keytab 文件的路径。
以下是一个示例完整的 VirtualHost 定义,其中 SimpleSAMLphp 安装在 /var/www/idp.example.com
<VirtualHost *:80> DocumentRoot /var/www/idp.example.com/www ServerName idp.example.com <Directory "/var/www/idp.example.com/www"> AllowOverride None Require all granted </Directory> <Location "/module.php/negotiateserver/auth.php"> AuthName "[MY_ORGANIZATION_NAME] Authentication" AuthType Kerberos Krb5Keytab /etc/httpd/conf/HTTP.idp.keytab KrbMethodNegotiate On KrbMethodK5Passwd On require valid-user </Location> </VirtualHost>
IIS 配置
在您的 SimpleSAMLphp 安装(例如,/var/www/idp.example.com/www)的 www 目录中创建一个 web.config 文件,内容如下
<?xml version="1.0" encoding="UTF-8"?> <configuration> <location path="module.php/negotiateserver/auth.php"> <system.webServer> <security> <authentication> <anonymousAuthentication enabled="false" /> <windowsAuthentication enabled="true" /> </authentication> </security> </system.webServer> </location> <system.webServer> <serverRuntime authenticatedUserOverride="UseWorkerProcessUser" /> </system.webServer> </configuration>
模块配置
所有 negotiateserver 模块配置都在 authsources.php 中处理。在 config/authsources.php 内部 $config 数组中添加以下条目
'negotiateserver' => array( 'negotiateserver:Negotiate', // Entry in authsources.php that this module will // fallback to in case of an error 'auth_fallback' => 'ldap', // Connection parameters for your Active Directory or LDAP // from which user attributes will be retrieved after a successful // user authentication 'ldap.hostname' => '127.0.0.1', 'ldap.base' => ['OU=Users,OU=Example,DC=example,DC=local'], 'ldap.admin_user' => 'admin@example.local', 'ldap.admin_password' => 'password123', 'ldap.identifier' => 'sAMAccountName', // The list of attributes to retrieve from Active Directory or LDAP // (leave empty to retrieve all available attributes) 'attributes' => ['userPrincipalName', 'displayName', 'givenName', 'sn'], // Use this module only on the subnets defined below // (leave empty to enable it for all requests) 'subnets' => [ '10.0.0.0/16', ], // Use this module only on allowed subnets (or all requests) // except for the ones defined below 'subnets_exclude' => [ '10.0.5.0/24' ] ),
浏览器配置
Internet Explorer
Internet Explorer 使用安全区域来区分不同类型的网站。为了启用您站点的集成 Windows 身份验证,您应将其添加到 受信任站点 安全区域。
转到 Internet 选项 下的 安全 标签,选择 受信任站点 并点击 站点 按钮打开列表。
将您的身份提供者 URL 添加到列表中,然后关闭窗口。
Google Chrome
Google Chrome 将遵循上述 Internet Explorer 的设置。
Mozilla Firefox
要在 Firefox 中启用 HTTP Negotiate 身份验证,请转到 about:config 并承诺在更改这些高级设置时要小心。
搜索名为 network.negotiate-auth.trusted-uris 的首选项并将其身份提供者添加到列表中。