Using the Simple and Protected GSS-API Negotiation Mechanism(SPNEGO) in Geronimo allows HTTP users to log in and authenticate only once in their desktop, then they can receive automatic authentication from the Geronimo server.
Using the SPNEGO requires three distinct machines:
- A Microsoft Windows 2000 or Windows 2003 Server running the Active Directory Domain Controller and associated Kerberos Key Distribution Center(KDC)
- A domain member with internet browsers for example, a Microsoft Internet Explorer or Firefox browser
- A server Platform with Geronimo running
Note that the clock on clients, Microsoft Active Directory Domain Controller and Geronimo server must be synchronized to within five minutes, and they must be within the same domain.
Setting up the Domain Controller Machine
- Create a user account in the active directory. Make sure that the user you create is unique and not listed in Computers or domain controllers. This account will be eventually mapped to the Kerberoes service principal name(SPN).
- Map the user account to the SPN with the command setspn. Typically, A SPN looks like HTTP/<Fully_Qualified_Host_Name>. Make sure that you do not have the same SPNs mapping to more than one Microsoft user account. If you map the same SPN to more than one user account, the web browser client can send a NT LAN Manager(NTLM) authentication request instead of SPNEGO token to Geronimo server. See Windows 2003 Technical Reference (setspn command) for more usages of the command.
setspn -A HTTP/test.xyz.com testuser.
- testuser is the user account created in step1
- HTTP/test.xyz.com is the unique SPN mapped with testuser, test.xyz.com is the host name of Geronimo server.
- Create the Kereros keytab file(
krb5.keytab) with the command ktpass and make the file available to Geronimo server by copying it from the Domain Controller to the Geronimo server. See Windows 2003 Technical Reference (ktpass command) for more usages of the command.
ktpass -out c:\winnt\krb5.keytab -princ HTTP/test.xyz.com@XYZ.COM -mapUser testuser -mapOp set -pass testuser123 -crypto RC4-HMAC-NT -pType KRB5_NT_PRINCIPAL
- HTTP/test.xyz.com@XYZ.COM is the concatenation of the user logon name, and the realm name which must be in uppercase.
- testuser is the user account for mapping.
- testuser123 is the password of the user testuser.
Setting up the Client Application Machine
On client machines, the Web browsers are responsible for generating the SPNEGO token for user by the Geronimo server. Perform the following configuration for your browsers. Note that the resources on Geronimo server can only be accessible by the domain name of the Geronimo server, and the client machines must be the members of Domain.
Enable SPNEGO authentication in Microsoft Internet Explorer browser
- In the Internet Explorer windows, click Tools>Internet Options>Security tab.
- Select the Local Intranet icon and click Sites.
- Make sure all check boxes are selected in the Local Intranet windows, then click Advanced button.
- Add the URI name of the Geronimo server for example _http://test.xyz.com_ into the list Web sites so that the Single Sign-On (SSO) can be enabled, then click OK to complete this step and close the Local intranet window.
- On the Internet Options windows, click the Advanced tab and go to Security settings. Make sure Enable Integrated Windows Authentication(requires restart) check box is selected, then click OK to close all windows.
- Restart your Microsoft Internet Explorer to activate the configuration.
Enable SPNEGO authentication in Firefox
- In the URL address bar of your Firefox browser, type about:config and press the Enter key.
- In the following windows, type network.nego in the Filters.
- Double click network.negotiate-auth.trusted-uris and add http://,https:// in the pop-up window, then click OK to close the window.
- Double click network.negotiate-auth.delegation-ruis and add http://,https:// in the pop-up window, then click OK to close the window.
- Restart your Firefox to activate the configuration.
Setting up the Geronimo server
- Copy the Keroes keytab file
krb5.keytab to one of directories of your Geronimo Server. The file was created during Setting up the Domain Controller Machine.
- Create a basic Kerbeores configuration file named
krb5.ini in order to use the SPNEGO for the server. The files should be stored on local server and with the following keys list defining the Kerberoes key distribution center(KDC) name and the realm setting for the SPNEGO authentication.
- Configure JVM properties with the following key pairs to make sure the JVM read the Kerberoes configurations successfully.
set JAVA_OPTS=-Djava.security.krb5.conf=C:\winnt\krb5.ini -Dcom.ibm.security.jgss.debug=all -Dcom.ibm.security.krb5.Krb5Debug=all -Djavax.security.auth.useSubjectCredsOnly=false
- Create a system-scope realm for the Geronimo server as followed. The sample code is a combination of SPNEGO and .properties file realms in order that the authentication will fall back on .Properties realm once the SPNEGO authentication fails. You can remove the .properties file realm if unnecessary.
- Configure the deployment plan of your application to make sure the SPNEGO realm is invoked properly. See the sample code below for reference.
- Configure the deployment descriptor to make sure your application uses SPNEGO authentication and the respective realm provider that Geronimo server supports.
Few very important points to note
- Make sure that you use Basic as the authentication mechanism in your web application if you want to configure Spnego with geronimo.
- The realm provided is a combination of 2 login modules which can be easily created through geronimo administrative console.
- While you are creating a security realm for Spnego loginmodule you need to just specify one option that will be of the form "targetName=http/<fully_qualified_host_name>". Have a look at the sample realm. This will give you an idea of the option to be used.
- Make sure you choose sufficient as the control-flag while creating the 2 login modules.
- Make sure you map only one user to SPN as defined in #2 of "Setting up the Active Directory Domain Controller".