This documentation show how to configure Spring Boot 2 to authenticate with Kerberos (here, I'm using Windows AD).
Refs:
- Introduction to SPNEGO/Kerberos Authentication in Spring
- SSO in Spring Boot using Kerberos authentication in Microsoft Active Directory
- T-Heron's answer on Stackoverflow
- Spring Security Kerberos - Reference Documentation
Setting the user on AD: First of, you must create a valid user on AD. Don't forget to disable the option which force user to change his password on first logon.
After create the user, you must configure user in KDC.
Creating a keytab file:
To configure user in KDC, you will use the ktpass
command. This command is available on Windows Server (same server with AD).
According with T-Heron's answer on Stackoverflow, it's not necessary use the setspn
command, and in my tests, this is true.
So, the only command necessary is ktpass
. This must be executed on AD server.
Execute the following command to configure the user and generate a keytab file:
ktpass -out outputfile.keytab -princ HTTP/[fqdn]@[domain] -mapUser [user] -mapOp set -pass [password] -crypto ALL -pType KRB5_NT_PRINCIPAL
Where:
- [fqdn]: full qualified domain name. Must be the name, not IP. Example: server001.domain.intranet.com
- [domain]: domain name. Example: domain.intranet.com
- [user]: login name of user
- [password]: password of the user
Example:
Domain: domain.intranet.com
Username: user001
Password: secret123
Hostname of the service: server001
ktpass -out keys.keytab -princ HTTP/[email protected] -mapUser user001 -mapOp set -pass secret123 -crypto ALL -pType KRB5_NT_PRINCIPAL
It's recommended that the service that will use the Kerberos authentication be on a different host than Windows AD.
Configure Chrome and Internet Explorer to authenticate via Kerberos:
On Internet Explorer
, check the Security Tab
on Options, and on Intranet Zone
, add the hostname of service as trusted site.
Chrome will get the configuration from Internet Explorer.
Check example below to see how to use Kerberos Authentication with Spring Boot.
You must navigate with the full qualified host name...
http://localhost, http://server001, http://127.0.0.1 will not work! Must be something like http://server001.domain.intranet.com