简体   繁体   English

如何使用 Microsoft AD 为内部 PHP 应用程序实施单点登录 (SSO)?

[英]How can I implement single sign-on (SSO) using Microsoft AD for an internal PHP app?

I'm vaguely aware that on a computer joined to a domain IE can be asked to send some extra headers that I could use to automatically sign on to an application.我隐约意识到在加入域的计算机上,可以要求 IE 发送一些额外的标头,我可以使用这些标头自动登录到应用程序。 I've got apache running on a windows server with mod_php.我有 apache 在带有 mod_php 的 windows 服务器上运行。 I'd like to be able to avoid the user having to log in if necessary.我希望能够避免用户在必要时必须登录。 I've found some links talking about Kerberos and Apache modules.我发现了一些谈论 Kerberos 和 Apache 模块的链接。

http://www.onlamp.com/pub/a/onlamp/2003/09/11/kerberos.html?page=last https://metacpan.org/pod/Apache2::AuthenNTLM http://www.onlamp.com/pub/a/onlamp/2003/09/11/kerberos.html?page=last https://metacpan.org/pod/Apache2::AuthenNTLM

Since I'm running on Windows it's proven to be non-trivial to get Perl or Apache modules installed.由于我在 Windows 上运行,事实证明安装 Perl 或 Apache 模块并非易事。 But doesn't PHP already have access to HTTP headers?但是 PHP 不是已经可以访问 HTTP 标头了吗?

I found this but it doesn't do any authentication, it just shows that PHP can read the NTLM headers.我找到了这个,但它没有进行任何身份验证,它只是表明 PHP 可以读取 NTLM 标头。 http://siphon9.net/loune/2007/10/simple-lightweight-ntlm-in-php/ http://siphon9.net/loune/2007/10/simple-lightweight-ntlm-in-php/

I'd like to be able to have my users just point to the application and have them automatically authenticated.我希望能够让我的用户指向应用程序并让他们自动进行身份验证。 Has anyone had any experience with this or gotten it to work at all?有没有人对此有任何经验或完全可以使用它?

UPDATE Since originally posting this question, we've changed setups to nginx and php-fcgi still running on windows. Apache2 and php-cgi on windows is probably one of the slowest setups you could configure on windows. It's looking like Apache might still be needed (it works with php-fcgi) but I would prefer a nginx solution.更新自最初发布此问题以来,我们已将设置更改为 nginx,并且 php-fcgi 仍在 windows 上运行。Apache2 和 windows 上的 php-cgi 可能是您可以在 8838236010511888 上配置的最慢的设置之一,它可能仍然像 888.8 一样看起来像 888.8需要(它适用于 php-fcgi),但我更喜欢 nginx 解决方案。

I also still don't understand (and would love to be educated) why HTTP server plugins are necessary and we can't have a PHP, web server agnostic solution.我仍然不明白(并且很想接受教育)为什么 HTTP 服务器插件是必需的,我们不能有 PHP、web 服务器不可知的解决方案。

All you need is the mod_auth_sspi Apache module.您只需要mod_auth_sspi Apache 模块。

Sample configuration:示例配置:

AuthType SSPI
SSPIAuth On
SSPIAuthoritative On
SSPIDomain mydomain

# Set this if you want to allow access with clients that do not support NTLM, or via proxy from outside. Don't forget to require SSL in this case!
SSPIOfferBasic On

# Set this if you have only one domain and don't want the MYDOMAIN\ prefix on each user name
SSPIOmitDomain On

# AD user names are case-insensitive, so use this for normalization if your application's user names are case-sensitive
SSPIUsernameCase Lower
AuthName "Some text to prompt for domain credentials"
Require valid-user

And don't forget that you can also use Firefox for transparent SSO in a Windows domain : Simply go to about:config , search for network.automatic-ntlm-auth.trusted-uris , and enter the host name or FQDN of your internal application (like myserver or myserver.corp.domain.com).并且不要忘记,您还可以在 Windows 域中使用 Firefox 进行透明 SSO :只需将 go 设置为about:config ,搜索network.automatic-ntlm-auth.trusted-uris ,然后输入您内部网络的主机名或 FQDN应用程序(如 myserver 或 myserver.corp.domain.com)。 You can have more than one entry, it's a comma-separated list.您可以有多个条目,它是一个以逗号分隔的列表。

I had a similar problem which I needed to solve for my organization.我有一个类似的问题需要为我的组织解决。

I was looking into using adLDAP .我正在研究使用adLDAP

There is some documentation on the site for achieving seamless authentication with Active Directory too.站点上也有一些文档可以实现与 Active Directory 的无缝身份验证。

I'd be curious about a solution that uses OpenID as a backend (of sorts) for this... I wasn't seeing anything that would hook into ActiveDirectory directly when I googled (quickly).我很好奇一个使用 OpenID 作为后端(某种)的解决方案......当我用谷歌搜索(快速)时,我没有看到任何可以直接连接到 ActiveDirectory 的东西。 However, it could be pretty painless to implement over plain HTTP(S) (you'd be an OpenID provider that checked credentials against your local AD).但是,通过纯 HTTP(S) 实现可能非常轻松(您将是一个 OpenID 提供者,根据您的本地 AD 检查凭据)。 In a best case scenario, you might be able to just add a couple classes to your app and be off and running -- no web server modules required.在最好的情况下,您可能只需向您的应用程序添加几个类,即可关闭并运行——不需要 web 服务器模块。 There is a lot of open source code out there for either side of this, so if nothing else, it's worth taking a look.这方面的任何一方都有很多开源代码,所以如果不出意外,值得一看。 If you exposed the backend to the users (ie gave them OpenID URLs), you'd have the added benefit of them being able to log in to more than just your internal sites using these credentials.如果您向用户公开后端(即给他们 OpenID URL),您将获得额外的好处,即他们能够使用这些凭据登录到您的内部站点之外的其他站点。 (Example: Stack Overflow.) (例如:堆栈溢出。)

As an aside, I'd be against making it so that Inte.net Explorer is required.顺便说一句,我反对要求使用 Inte.net Explorer。 I'm not sure if that is the goal from the way you wrote the question, but depending on your IT environment, I'd expect people who use Firefox or Safari (or Opera or...) to be less than enthusiastic.我不确定这是否是您编写问题的方式的目标,但根据您的 IT 环境,我希望使用 Firefox 或 Safari(或 Opera 或...)的人不会那么热情。 (You're not developing against IE first, are you? That's been painful whenever I've done so.) This is not to say that you couldn't use this feature of IE, just that it shouldn't be the only option. (您不会首先针对 IE 进行开发,是吗?每当我这样做时,这都很痛苦。)这并不是说您不能使用 IE 的这个功能,只是它不应该是唯一的选择. The link you posted stated that NTLM worked with more than IE, but since I don't have any experience with it, it's hard to judge how well that would work.您发布的链接指出 NTLM 不仅仅适用于 IE,但由于我没有任何经验,因此很难判断它的效果如何。

One option for you is to use CAS (central authentication service).您的一种选择是使用 CAS(中央身份验证服务)。

It has php client library.它有 php 客户端库。

How-to link to MS Active Directory: http://www.ja-sig.org/wiki/display/CASUM/Active+Directory如何链接到 MS Active Directory: http://www.ja-sig.org/wiki/display/CASUM/Active+Directory

You would require Apache maven 2 though.不过,您需要 Apache maven 2。

For IIS/PHP FCGI, You need to send out an unauthorized header:对于IIS/PHP FCGI,你需要发出未经授权的header:

function EnableAuthentication()
{
    $realm = "yoursite";
    header('WWW-Authenticate: Digest realm="'.$realm.'",qop="auth",nonce="'.uniqid().'",opaque="'.md5($realm).'"');
    header("HTTP/1.1 401 Unauthorized"); 
    exit;
}

You can then get at the username with:然后,您可以通过以下方式获取用户名:

$winuser = $_SERVER["REMOTE_USER"];

I then make sure the $winuser is in my database of allowed users.然后我确保 $winuser 在我的允许用户数据库中。

Be SURE and test this under a non-privileged account.请务必在非特权帐户下进行测试。 When I first installed this I tested it and it worked fine, but later when a standard non-server-admin user tried it this failed.当我第一次安装它时,我测试了它并且工作正常,但后来当一个标准的非服务器管理员用户尝试它时失败了。 Turns out some of the temporary directories need to have permissions changed for guest users.事实证明,一些临时目录需要为来宾用户更改权限。 I can't recall the exact settings.我不记得确切的设置。

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

相关问题 使用Web服务在ASP.NET和PHP中进行SSO(单点登录)? - SSO(Single Sign-on) in ASP.NET and Php using Webservices? 如何使用PHP表单在ASP.NET / C#中为单点登录(SSO)生成URL? - How to generate URL in ASP.NET / C# for a Single Sign-On (SSO) using PHP form? 对Web应用程序使用单点登录(sso)时的数据库检查(用于凭据),提示? - database check (for credentials) when using single sign-on (sso) for a web app, hint? 单点登录(SSO)如何与PHP + Apache一起针对Active Directory进行透明身份验证? - How does single sign-on (SSO) work with PHP + Apache against an Active Directory for transparent authentication? 为两个PHP网站实施单点登录的策略是什么? - What's the strategy to implement single sign-on for two PHP websites? IBM (ISAM)、单点登录和 PHP Web 应用程序 - IBM (ISAM) , Single Sign-on and a PHP Web App 当有人登录我的网站时,如何自动创建phpBB会话? (单点登录) - How can I automatically create a phpBB session when someone logs onto my website? (Single sign-on) 如何将Azure AD集成到使用AWS Cognito实现SSO的应用程序中? - How can I integrate Azure AD into my app which implements SSO using AWS Cognito? 通过 PHP 中的单点登录或登录 - Single Sign-on or login via in PHP 单一登录ASP.NET和PHP - Single Sign-On ASP.NET and PHP
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM