SPNEGO authentication
SPNEGO authentication enables users who are logged into their Windows workstation with their domain account to automatically authenticate into CAS and, transitively, into services using CAS authentication. As a result, authentication is seamlessly delegated to Active Directory.
-
Prerequisites
-
MS AD settings and keytab generation
-
Configuration file preparation
-
CAS configuration
-
Browser settings
-
Testing
Prerequisites
The tutorial uses following values and examples. Change them according to your environment.
Item | Value in examples |
---|---|
Domain controller (DC), Microsoft Active Directory (MSAD, AD) |
|
Appliance hostname on which the services are available |
You must always use the full hostname. NetBIOS-style (or other) hostname fragments without specifying the domain are not supported. |
AD domain |
The value must always be in uppercase. |
Name of the service registered in AD (Service principal name, SPN). |
|
The user account name in AD (UPN logon name) to which the registered service is bound. |
|
MS AD settings and keytab generation
-
Create a dedicated user in MS AD.
-
In the Active Directory Administrative Center application, navigate to the relevant domain and create a new user account.
-
Set the user’s UPN logon to
cas-user@domain.tld
. -
Set
sAMAccountName
tocas-user
. The value is usually the same as UPN but without the domain. Thektpass
utility used later will change the user’s name to the correct value. -
Set any first and last name.
-
Set following account properties:
-
Account expires:
never
-
Password never expires
(under Password options, Other password options) -
User cannot change password
(under Password options, Other password options) -
Under
Encryption options
, set:-
This account supports Kerberos AES 128 bit encryption
-
This account supports Kerberos AES 256 bit encryption
-
-
-
Set a password for the account and save it. The password must be set after all the configuration above is finished, otherwise some settings may not take effect.
-
-
Open the command line (
cmd
) and generate the user’s keytab with the command:ktpass -out file.keytab -princ HTTP/iam-appliance.tld@DOMAIN.TLD -mapUser cas-user@domain.tld -crypto all -pass * -ptype KRB5_NT_PRINCIPAL
-
Enter new password. It doesn’t need to be the same as the password for the user.
-
Download the keytab file
file.keytab
, you will need to upload it to the appliance.
If you make a mistake when using the ktpass tool, you cannot simply run it again. If you do, multiple SPN records will be created in AD and the integration would not work. If you make a mistake, delete the cas-user@domain.tld completely and create it again.
|
Configuration file preparation
You need to prepare the following files for the SPNEGO authentication in CAS:
-
file.keytab
- we generated it in the previous step, upload it to the appliance server -
krb5.conf
- there is a template in the appliance which needs to be modified -
login.conf
- there is a template in the appliance but it usually doesn’t require any modification
file.keytab
Upload the generated file file.keytab
to the appliance, to the /data/volumes/cas/spnego/
directory.
krb5.conf
The file contains information about the domain and its KDC (Key Distribution Center, in the case of AD, this service is provided by the domain controller).
The file template is located in /data/volumes/cas/spnego/krb5.conf
. In the file, you need to change the domain name. It is present in several places in different formats, such as EXAMPLE.COM
or example.com
. Replace all these occurrences with the domain name, while preserving the current format (lower vs. upper case, periods at the beginning of the string, etc.).
Furthermore, the KDC hostname needs to be changed (on line kdc = kdc.example.com:88
), use the domain controller as the KDC.
In our example, the resulting file will look like this:
[logging] default = FILE:/var/log/krb5libs.log kdc = FILE:/var/log/krb5kdc.log admin_server = FILE:/var/log/kadmind.log [libdefaults] ticket_lifetime = 24000 default_realm = DOMAIN.TLD default_keytab_name = /etc/cas/config/file.keytab dns_lookup_realm = false dns_lookup_kdc = false default_tgs_enctypes = rc4-hmac des-cbc-md5 des-cbc-crc aes128-cts-hmac-sha1-96 aes256-cts-hmac-sha1-96 default_tkt_enctypes = rc4-hmac des-cbc-md5 des-cbc-crc aes128-cts-hmac-sha1-96 aes256-cts-hmac-sha1-96 [realms] DOMAIN.TLD = { kdc = ad.domain.tld:88 } [domain_realm] .domain.tld = DOMAIN.TLD domain.tld = DOMAIN.TLD
CAS configuration
Using nano
or vim
, edit the CAS configuration file located in /data/registry/node-active-config/docker-compose-cas.yml
. Find the following keys, uncomment them and change the values. In our example, the result will look like this:
- CAS_SPNEGO_ENABLED=true - CAS_KERBEROS_REALM=DOMAIN.TLD - CAS_KERBEROS_DEBUG=false - CAS_KERBEROS_KDC=ad.domain.tld - CAS_KERBEROS_SERVICE_PRINCIPAL=HTTP/iam-appliance.tld@DOMAIN.TLD
After editing the configuration, restart CAS with the command systemctl restart iam-cas.service
.
You can add multiple items to - CAS_KERBEROS_KDC if you use multiple KDCs. Separate each KDC with one space.
|
Browser settings
If you use Google Chrome or Microsoft Edge, set the configuration in the dialog "Internet Options" in Internet Explorer. These browsers load the SPNEGO configuration from IE. |
Internet Explorer
Start Internet Explorer and navigate to Internet Options (under the gear wheel) > Security > Trusted Sites
. Click on Sites
, then under Add this website to the zone
, write https://iam-appliance.tld
(appliance hostname).
Then, navigate to Internet Options > Security > Trusted Sites > Custom level
, under User Authentication > Logon
, check the option Automatic logon with current user name and password
.
Firefox
To the Firefox address line, enter about:config
and confirm that you want to make changes. To the search field, enter network.negotiate-auth.trusted-uris
, open the option and enter https://iam-appliance.tld
(appliance hostname).
Testing
Log in to Windows with you domain account. In a configured browser, go to https://iam-appliance.tld/cas/login
. If the SPNEGO is working, you will see in the browser that you were logged in successfully. If not, you will see the CAS login dialog. If that happens, the configuration needs to be debugged. The CAS log can be found in /data/logs/cas/cas.log
.
For testing and debugging, we recommend you change the debug level in the configuration file /data/registry/node-active-config/docker-compose-czechidm.yml , key - CAS_KERBEROS_DEBUG= , to the value true . Once you finished testing, do not forget to change the value back to false , otherwise the size of the logs will increase significantly and the log will be difficult to make sense of.
|