We have successfully setup SSO using Kerberos with a Java EE application and authenticating against a Windows Active Directory after many weeks of trials and web crawling.
JBOSS Negotiation and Spring Kerberos have both worked for us. However, both sets of documentation are not accurate enough to get you off the ground running. Put simple for either solution...
- Create Service User in Active Directory.
- Use ktpass to create a keytab file for this user. (Many gotchas with ktpass as listed below)
- Use setspn -A to fix ktpass.
- Ensure your krb5.conf (linux) or krb5.ini (windows) is correct.
- Ensure you are not running the client on the same box as a server.
- Ensure your times are in sync across your domain.
- Test Kerberos using kinit in the JDK.
- Configure your web application to delegate authentication via the provided filter.
- Configure an XML file to use the appropriate service principal user as created initially.
- Run your service as the principal user!!!!!!!!!
- If using Spring, you can then implement a UserDetailsService to query LDAP (active directory) and set roles on the user principal.
- From within your application the user principal should !=null.
ktpass problems:
- Ensure your service user is set to user cannot change password in Active Directory.
- Ensure you provide the password in the command line.
- Ensure that you can still open a command prompt as that user after generating the keytab.
- Ensure you specify the KRB5_NT_PRINCIPAL.
- Format should be
ktpass /out c:\service.keytab /mapuser userservice@TESTDOMAIN.SERVER.COM /princ HTTP/hostname@TESTDOMAIN.SERVER.COM /pass /ptype KRB5_NT_PRINCIPAL
- Add the fully qualified service principal using setspn -A as follows:
setspn –A HTTP/hostname.testdomain.server.com userservice
- DO NOT RESET THE SERVICE PRINCIPAL USERS PASSWORD (You will have to regenerate your keytab).
Finally, before every single test, use kinit purge to clear cached tickets.
Also, duplicate SPN's will break things badly! setspn -X in windows server 2008 will detect this (or google for script), if in doubt when doing this, start afresh with new service user and principal name every time!
Hope this helps someone avoid the pain I've had.