I have a setup with an Active Directory KDC, Windows 7 client workstations, and a Linux server (CentOS and Apache) outside the network with which I am trying to configure single sign on functionality. I'm having trouble getting the handshake to work between the client workstation and the Apache webserver. When I go to https://cname.mysite.com/user/login/sso, I get a 500 internal server error. I configured Firefox by going to "about:config" and adding "cname.mysite.com" to "network.negotiate-auth.trusted-uris" and "network.negotiate-auth.delegation-uris". I figured I would have to configure the browser with the A Record instead of the CName, but when I do this I just get a 401 authorization required error and not much else happens (same as if I didn't configure browser for kerberos at all). When the browser is configured with the CName, I get the 500 error and couple of interesting things happen:
1) If I'm on a workstation within the network, I get a ticket for the service that appears to be correct. A klist looks like this:
Cached Ticket (#2 of 7)
Client: active_directory_user@EXAMPLE.ORG
Server: HTTP/arecord.mysite.com@EXAMPLE.ORG
KerbTicket Encryption Type: RSADSI RC4-HMAC(NT)
Ticket Flags 0x40a00000 -> forwardable renewable pre_authent
Start Time: 10/24/2013 15:16:14 (local)
End Time: 10/25/2013 0:11:33 (local)
Renew Time: 10/31/2013 14:11:33 (local)
Session Key Type: RSADSI RC4-HMAC(NT)
2) I see the following in the Apache error logs:
"GSS-API major_status:000d0000, minor_status:000186a4" which I understand to simply mean that Apache can't read the keytab file.
"gss_acquire_cred() failed: Unspecified GSS failure. Minor code may provide more information (, )" which could mean the keytab has the wrong key version #, or machine password. It could also be a problem with the ticket cache on the workstation.
I've tried to make it so Apache can read the keytab file by changing its ownership to the user that owns the httpd Apache process (chown root) and making sure that it is readable by that user (chmod 400). However when I do this, the command to test if the keytab works on the webserver (kinit -k -t /etc/krb5.keytab HTTP/arecord.mysite.com) no longer finishes without error. Instead I receive "kinit: Generic preauthentication failure while getting initial credentials".
Here is some additional info about our setup:
If I do "kinit active_directory_user" from the webserver, I get prompted for a password and when entered correctly it completes without error. I can then use "klist" to view what appears to be a proper ticket granting ticket (service principal = krbtgt/EXAMPE.ORG@EXAMPLE.ORG).
I can then do "kvno HTTP/arecord.mysite.com" and I receive "HTTP/arecord.mysite.com@EXAMPLE.ORG: kvno = 6". I then check this against the keytab via "klist -k" and the kvno and principal match exactly. This also caches a service ticket so "klist" reveals a second ticket with HTTP/arecord.mysite.com@EXAMPLE.ORG as the service principal.
Finally I test if the keytab works on the server using: "kinit -k -t /etc/krb5.keytab HTTP/arecord.mysite.com" and it completes without error (unless the keytab user is changed to root as mentioned above).
Here is the configuration of our /etc/krb5.conf file (I recently stripped this down in hopes to fix the issue):
[libdefaults]
default_realm = EXAMPLE.ORG
[domain_realm]
arecord.mysite.com = EXAMPLE.ORG
[realms]
EXAMPLE.ORG = {
admin_server = ip address of dc/kdc
kdc = ip address of dc/kdc
}
Our webserver uses virtual hosts to host multiple websites. So the httpd.conf file uses "include" to reference to another site specific .conf file where I added this mod_auth_kerb logic:
LoadModule auth_kerb_module /path/to/modules/mod_auth_kerb.so
<Location /user/login/sso>
AuthType Kerberos
KrbAuthRealms EXAMPLE.ORG
KrbMethodNegotiate on
KrbMethodK5Passwd off
KrbServiceName HTTP/arecord.mysite.com@EXAMPLE.ORG
Krb5Keytab /etc/krb5.keytab
require valid-user
</Location>
I worked with the IT staff that maintains the Active Directory Domain Controller (the KDC in this case) to create a keytab file using ktpass:
ktpass /pass <password for account> /mapuser <username for account> /out c:\location\of\file\output\krb5.keytab /princ HTTP/arecord.mysite.com@EXAMPLE.ORG /ptype KRB5_NT_PRINCIPAL /crypto RC4-HMAC-NT /Target EXAMPLE.ORG
I also asked them to use "setspn -q HTTP/arecord.mysite.com" on the Active Directory DC to check for duplicate SPNs and it returns "Existing SPN Found!" which I believe means that it is okay. There are two SPN's listed however: HTTP/arecord.mysite.com@EXAMPLE.ORG and HTTPS/arecord.mysite.com@EXAMPLE.ORG because the first time we created the keytab, we didn't realize the host (HTTP in this case) referred to a service class that encompasses both the HTTP and HTTPS protocols.
Things that are done:
-synched clocks between AD server and Apache server via NTP (Luigi The Cat's post was helpful: http://community.spiceworks.com/topic/143891-possible-to-synchronize-ntp...)
-had our IP provider set up a PTR record that points the webserver's IP to the A Record for the site.
Things I've tried:
-moving the keytab record higher up in the directory structure
-reinstalling mod_auth_kerb from source: http://sourceforge.net/projects/modauthkerb/files/ and according to instructions: http://modauthkerb.sourceforge.net/install.html
-increasing the permissions for keytab file
-disabling SElinux
My setup closely resembles this closed issue: https://drupal.org/node/1777528#comment-form
I have been following advice from these guides:
http://www.grolmsnet.de/kerbtut/
http://acksyn.org/?p=460
These have been helpful for debugging errors:
http://publib.boulder.ibm.com/infocenter/tivihelp/v2r1/index.jsp?topic=%...
http://blog.stefan-macke.com/2011/04/19/single-sign-on-with-kerberos-usi...
Any advice is appreciated, please let me know if I need to provide additional information or test anything. Thanks so much!
Comments
Comment #1
Jimbo Slice commentedThis issue has been resolved. Here are some of the things that worked in my particular case:
I was finally able to removed the "GSS-API major_status:000d0000, minor_status:000186a4" Apache log error. It was exactly what I thought it was: Apache not being able to read the keytab file. The way I corrected this was:
1) Editing the httpd.conf file and changing the "User" and "Group" lines to a new user and group. This is where you establish the owner of the Apache process. Remember to restart Apache when you've edited the httpd.conf file to ensure these changes to take effect (sudo service httpd restart).
2) I added another keytab file for Apache specifically. This was just an exact duplicate of the /etc/krb5.keytab file but in a different location. I changed this file to have the same user and group as I specified in the httpd.conf file above (sudo chown username:groupname /path/to/apache-specific/keytab/krb5.keytab). I also changed the permissions on this new keytab file so it is only readable by the Apache user (sudo chown 400 /path/to/apache-specific/keytab/krb5.keytab).
After making the above changes, when hitting https://cname.mysite.com/user/login/sso and having Firefox configured (about:config > network.negotiate-auth.trusted-uris = .mysite.com), I was receiving the following in the Apache error log:
[info] Subsequent (No.2) HTTPS request received for child 1 (server arecord.mysite.com:80)
[debug] src/mod_auth_kerb.c(1628): [client ] kerb_authenticate_user entered with user (NULL) and auth_type Kerberos
[debug] src/mod_auth_kerb.c(1240): [client ] Acquiring creds for HTTP/arecord.mysite.com@EXAMPLE.ORG
[debug] src/mod_auth_kerb.c(1385): [client ] Verifying client data using KRB5 GSS-API
[debug] src/mod_auth_kerb.c(1401): [client ] Client didn't delegate us their credential
[debug] src/mod_auth_kerb.c(1420): [client ] GSS-API token of length 180 bytes will be sent back
[debug] ssl_engine_kernel.c(1889): OpenSSL: Write: SSL negotiation finished successfully
Which is exactly what should be logged during successful login according to this (near the bottom): http://blog.stefan-macke.com/2011/04/19/single-sign-on-with-kerberos-usi...
Another problem I had was that we are using HTTP authentication to protect the site using the Shield module (https://drupal.org/project/shield). So when I would hit the URL, I would get prompted for HTTP auth credentials and when the credentials were entered correctly, I would be sent to the 401 Authorization Required screen. The successful Apache log message was being logged before entering these credentials. Disabling shield seemed to do the trick.
I was still having a problem actually getting logged into the site after disabling shield. Hitting https://cname.mysite.com/user/login/sso would redirect me to our default login screen and display the following error message at the top of the page: "you have been successfully authenticated". This was odd because I was still not authorized to access content. Turns out to be something that is fixed in the newest version of the LDAP module (7.x-2.0-beta6 at the time of this posting). Upgrading fixed this for me, see this issue for more details: https://drupal.org/node/1956224
Here is the final working setup of my httpd.conf file (In my case it was actually a site specific .conf file because we are hosting multiple sites on the same server using vhosts. The httpd.conf file uses an "include" to reference this site specific file):
I hope this can help someone facing similar issues.
Comment #2
duke786 commentedI just followed all steps you have mentioned in this post as well as following links you have mentioned on this post. I must say it was very useful to follow for beginner in DRUPAL as well as in CENTOS.
I have encounter am error message:
[Mon Dec 23 05:44:52 2013] [error] [client private IP] gss_acquire_cred() failed: Unspecified GSS failure. Minor code may provide more information (, )
[Mon Dec 23 05:50:21 2013] [error] [client public IP] gss_acquire_cred() failed: Unspecified GSS failure. Minor code may provide more information (, ), referer: http://dns(A)record.my-domain.co.uk/admin/settings/ldap/sso
This above message appears as soon as I enable ALIAS under HTTPD.conf
Alias /sso/ "/var/www/test/"
AuthType Kerberos
KrbAuthRealms MY-DOMAIN.LOCAL
KrbServiceName HTTP
Krb5Keytab /etc/krb5.keytab
KrbMethodNegotiate on
KrbMethodK5Passwd off
require valid-user
When I browse site in chrome its giving me 500 error and in Mozilla 401.
please help....