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

前端 未结 5 1617
醉梦人生
醉梦人生 2020-12-04 12:31

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. I\'ve got ap

相关标签:
5条回答
  • 2020-12-04 13:01

    All you need is the mod_auth_sspi Apache module.

    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). You can have more than one entry, it's a comma-separated list.

    0 讨论(0)
  • 2020-12-04 13:05

    One option for you is to use CAS (central authentication service).

    It has php client library.

    How-to link to MS Active Directory: http://www.ja-sig.org/wiki/display/CASUM/Active+Directory

    You would require Apache maven 2 though.

    0 讨论(0)
  • 2020-12-04 13:08

    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). 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). 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. 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 (i.e. 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. (Example: Stack Overflow.)

    As an aside, I'd be against making it so that Internet Explorer is required. 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. (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. 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.

    0 讨论(0)
  • 2020-12-04 13:14

    I had a similar problem which I needed to solve for my organization.

    I was looking into using adLDAP.

    There is some documentation on the site for achieving seamless authentication with Active Directory too.

    0 讨论(0)
  • 2020-12-04 13:18

    For IIS/PHP FCGI, You need to send out an unauthorized 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.

    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.

    0 讨论(0)
提交回复
热议问题