Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 2. How to Setup SSO for Red Hat JBoss Enterprise Application Platform 6 with Kerberos
This section covers how to configure JBoss EAP 6 and the deployed applications to use Kerberos for SSO.
2.1. Components
The following components are needed for setting SSO for JBoss EAP 6 with Kerberos:
- A properly configured Kerberos environment
- A JBoss EAP 6 instance
- A web application
2.1.1. JBoss Negotiation Toolkit
The JBoss Negotiation Toolkit is a debugging tool which is available for download from https://community.jboss.org/servlet/JiveServlet/download/16876-2-34629/jboss-negotiation-toolkit.war. It is provided as an extra tool to help users to debug and test the authentication mechanisms before introducing an application into production. It is an unsupported tool, but is considered to be very helpful, as SPNEGO can be difficult to configure for web applications.
2.1.2. Kerberos Environment
As discussed in a previous section, Kerberos relies on a third party (the KDC), to provide authentication and authorization decisions. This also requires clients (e.g. browsers) and their host to be properly configured to authenticate with the KDC. This guide is primarily focused on how to configure JBoss EAP 6 and its hosted web applications so configuring the KDC and Kerberos domain are not in the scope of this document.
The subsequent sections assume a KDC and Kerberos domain have already been set up and properly configured.
2.1.3. Differences from Configuring Previous Versions Red Hat JBoss Enterprise Application Platform
There are a few noticeable differences between JBoss EAP 6 and earlier versions:
-
Security domains are configured for each profile of a managed domain, or for each standalone server. They are not part of the deployment itself. The security domain a deployment should use is named in the deployment’s
jboss-web.xml
orjboss-ejb3.xml
file. - Security properties are configured as part of a security domain. They are not part of the deployment.
-
Authenticators can no longer be overriden as part of a deployment. However, a NegotiationAuthenticator valve can be added to the
jboss-web.xml
descriptor to achieve the same effect. The valve still requires the <security-constraint> and <login-config> elements to be defined in theweb.xml
. These are used to decide which resources are secured. However, the chosen auth-method will be overridden by the NegotiationAuthenticator valve in thejboss-web.xml
. - The CODE attributes in security domains now use a simple name instead of a fully-qualified class name. The below table shows the mappings between the classes used for JBoss Negotiation, and their classes.
Simple Name | Class Name | Purpose |
---|---|---|
Kerberos | com.sun.security.auth.module.Krb5LoginModule | Kerberos login module when using the Oracle JDK |
Kerberos | com.ibm.security.auth.module.Krb5LoginModule | Kerberos login module when using the IBM JDK |
SPNEGO | org.jboss.security.negotiation.spnego.SPNEGOLoginModule | The mechanism which enables your Web applications to authenticate to your Kerberos authentication server. |
AdvancedLdap | org.jboss.security.negotiation.AdvancedLdapLoginModule | Used with LDAP servers other than Microsoft Active Directory. |
AdvancedAdLdap | org.jboss.security.negotiation.AdvancedADLoginModule | Used with Microsoft Active Directory LDAP servers. |
2.1.4. Configuring the Red Hat JBoss Enterprise Application Platform 6 Instance
JBoss EAP 6 comes with all the components necessary to use Kerberos (via SPNEGO and JBoss Negotiation) for SSO with deployed applications, but the following configuration changes need to be made:
The CLI commands shown below were done assuming a standalone instance of JBoss EAP 6. For more details on using the CLI with JBoss EAP 6 domains, please consult The Management CLI section of the Red Hat JBoss Enterprise Application Platform 6 Administration and Configuration Guide.
2.1.4.1. 1. Configuring Server Identity (Host) Security Domain
This security domain authenticates the container itself to the KDC. It needs to use a login module which accepts a static login mechanism since a real user is not involved in this connection. The below example uses a static principal and references a keytab file which contains the credential.
Example CLI for Creating a Server Identity Security Domain
/subsystem=security/security-domain=host:add(cache-type=default)
/subsystem=security/security-domain=host/authentication=classic:add
/subsystem=security/security-domain=host/authentication=classic/login-module=Kerberos:add( \ code=Kerberos, \ flag=required, \ module-options=[ \ ("storeKey"=>"true"), \ ("refreshKrb5Config"=>"true"), \ ("useKeyTab"=>"true"), \ ("principal"=>"host/testserver@MY_REALM"), \ ("keyTab"=>"/home/username/service.keytab"), \ ("doNotPrompt"=>"true"), \ ("debug"=>"false") \ ])
reload
Resulting XML
<security-domain name="host" cache-type="default"> <authentication> <login-module code="Kerberos" flag="required"> <module-option name="storeKey" value="true"/> <module-option name="useKeyTab" value="true"/> <module-option name="principal" value="host/testserver@MY_REALM"/> <module-option name="keyTab" value="/home/username/service.keytab"/> <module-option name="doNotPrompt" value="true"/> <module-option name="debug" value="false"/> </login-module> </authentication> </security-domain>
If using the IBM JDK, options for Kerberos module are different. The jboss.security.disable.secdomain.option system property must be set to true (see Configure Relevant System Properties). In addition the login module should be updated to the following:
IBM JDK Example
<security-domain name="host" cache-type="default"> <authentication> <login-module code="Kerberos" flag="required"> <module-option name="principal" value="HTTP/testserver@MY_REALM"/> <module-option name="credsType" value="acceptor"/> <module-option name="useKeytab" value="file:///root/keytab"/> </login-module> </authentication> </security-domain>
For a complete list of options for configuring the Kerberos login module, refer to the Red Hat JBoss Enterprise Application Platform 6 Security Guide.
2.1.4.2. 2. Configuring Web Application Security Domain
The web application security domain is used to authenticate the individual user to the KDC. There needs to be at least one login module to authenticate the user, and a way to search for the roles to apply to the user. The latter can be accomplished in many different ways (e.g. adding a <mapping>
that manually maps users to roles, adding a second login module for mapping users to roles, etc).
The following shows an example web application security domain.
Example CLI for Creating a Server Identity Security Domain
/subsystem=security/security-domain=app-spnego:add(cache-type=default)
/subsystem=security/security-domain=app-spnego/authentication=classic:add
/subsystem=security/security-domain=app-spnego/authentication=classic/login-module=SPNEGO:add( \ code=SPNEGO, \ flag=required, \ module-options=[ \ ("serverSecurityDomain"=>"host") \ ])
reload
Resulting XML
<security-domain name="app-spnego" cache-type="default"> <authentication> <!-- Check the username and password --> <login-module code="SPNEGO" flag="required"> <module-option name="serverSecurityDomain" value="host"/> </login-module> <!-- Second login module to search for roles --> </authentication> <!-- Alternatively, a 'mapping' element may be added instead of a second login module to map users to roles--> </security-domain>
For a complete list of options for configuring the SPNEGO login module, refer to the Red Hat JBoss Enterprise Application Platform 6 Security Guide.
2.1.4.3. 3. Configuring Relevant System Properties
JBoss EAP 6 offers the ability to configure system properties related to connecting to Kerberos servers. Depending on the KDC, Kerberos Domain, and network configuration, the below system properties may or may not be required.
<system-properties> <property name="java.security.krb5.kdc" value="mykdc.mydomain"/> <property name="java.security.krb5.realm" value="MY_REALM"/> <property name="java.security.krb5.conf" value="/path/to/krb5.conf"/> <property name="jboss.security.disable.secdomain.option" value="true"/> <property name="sun.security.krb5.debug" value="false"/> </system-properties>
Value | Description |
---|---|
java.security.krb5.kdc | The host name of the KDC |
java.security.krb5.realm | The name of the realm |
java.security.krb5.conf |
The path to the configuration |
jboss.security.disable.secdomain.option | When set to true, disables automatic adding of jboss.security.security_domain login module option to login modules declared in the security domain. Must be set to true when using the IBM JDK |
sun.security.krb5.debug | If true, debugging mode will be enabled |
By default, each login module defined in a security domain has the jboss.security.security_domain module option added to it automatically. This option causes problems with login modules which check to make sure that only known options are defined. The IBM Kerberos login module, com.ibm.security.auth.module.Krb5LoginModule is one of these. This behavior of adding this module option can disabled by setting the jboss.security.disable.secdomain.option system property to true when starting JBoss EAP 6. This can be accomplished by configuring the <system-properties> (via the Management CLI or Management Console) or by adding -Djboss.security.disable.secdomain.option=true
to the start-up parameters.
For more information about configuring system properties, refer to the Configure System Properties Using the Management CLI section of the Red Hat JBoss Enterprise Application Platform 6 Administration and Configuration Guide.
2.1.5. Configuring the Web Application
Once the security domains have been configured, the web application must be configured to use those security domains in order to enable Kerberos authentication. The following updates must be made the application:
Once the application changes have been made, it may be deployed to the JBoss EAP 6 instance and begin using Kerberos for authentication.
2.1.5.1. 1. Configuring the web.xml to Use the SPNEGO Authentication Method
The web.xml
file should contain the following:
-
A
<security-constraint>
with a<web-resource-collection>
containing a<url-pattern>
that maps to the URL pattern of the secured area. Optionally,<security-constraint>
may also contain an<auth-constraint>
stipulating the allowed roles. -
If any roles were specified in the
<auth-constraint>
, those roles should be defined in a<security-role>
.
The <security-constraint>
and <security-role>
elements enable administrators to setup restricted or unrestricted areas based on URL patterns and roles. This allows resources to be secured or unsecured.
Example web.xml
file:
<web-app> <display-name>App1</display-name> <description>App1</description> <!-- Define a security constraint that requires the All role to access resources --> <security-constraint> <display-name>Security Constraint on Conversation</display-name> <web-resource-collection> <web-resource-name>exampleWebApp</web-resource-name> <url-pattern>/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>All</role-name> </auth-constraint> </security-constraint> <!-- Define the Login Configuration for this Application --> <login-config> <auth-method>SPNEGO</auth-method> <realm-name>SPNEGO</realm-name> </login-config> <!-- Security roles referenced by this web application --> <security-role> <description>Role required to log in to the Application</description> <role-name>All</role-name> </security-role> </web-app>
2.1.5.2. 2. Configuring the jboss-web.xml to Use the Configured Security Domain
The jboss-web.xml
file should have the following:
-
A
<security-domain>
to specify which security domain to use for authentication and authorization. -
A
<valve>
configured to use the NegotiationAuthenticator valve class (i.e. org.jboss.security.negotiation.NegotiationAuthenticator) -
Optional: A <jacc-star-role-allow>, which enables the use of the asterisk (*) character in role-name element in
web.xml
to match multiple role names.
An example jboss-web.xml
file:
<jboss-web> <security-domain>app-spnego</security-domain> <valve> <class-name>org.jboss.security.negotiation.NegotiationAuthenticator</class-name> </valve> <jacc-star-role-allow>true</jacc-star-role-allow> </jboss-web>
2.1.5.3. 3. Adding the JBoss Negotiation Dependencies to the Deployment
A web application using SPNEGO and JBoss Negotiation requires a dependency to be defined in jboss-deployment-structure.xml
so that the JBoss Negotiation classes can be located. Since JBoss EAP 6 provides all necessary JBoss Negotiation and related classes, the application just needs to declare them as dependencies to use them.
Using jboss-deployment-structure.xml to declare dependencies
<jboss-deployment-structure> <deployment> <dependencies> <module name="org.jboss.security.negotiation"/> </dependencies> </deployment> </jboss-deployment-structure>
Alternatively, this dependency may be defined in a META-INF/MANIFEST.MF
file instead:
Using META-INF/MANIFEST.MF to declare dependencies
Manifest-Version: 1.0 Build-Jdk: 1.6.0_24 Dependencies: org.jboss.security.negotiation
2.2. Additional Considerations for Active Directory
This section describes how to configure the accounts required for JBoss Negotiation to be used when JBoss EAP 6 is running on a Microsoft Windows server, which is a part of the Active Directory domain.
In this section, the hostname that is used to access the server as is referred to as HOSTNAME, realm is referred to as REALM, domain is referred to as DOMAIN, and the server hosting the JBoss EAP 6 instance is referred to as MACHINE_NAME.
2.2.1. Configure JBoss Negotiation for Microsoft Windows Domain
2.2.1.1. 1. Clear Existing Service Principal Mappings
On a Microsoft Windows network some mappings are created automatically. Delete the automatically created mappings to map the identity of the server to the service principal for negotiation to take place correctly. The mapping enables the web browser on the client computer to trust the server and attempt SPNEGO. The client computer verifies with the domain controller for a mapping in the form of HTTP/HOSTNAME.
The following are the steps to delete the existing mappings:
List the mapping registered with the domain for the computer using the command:
setspn -L MACHINE_NAME
Delete the existing mappings using the commands:
setspn -D HTTP/HOST_NAME MACHINE_NAME
setspn -D host/HOSTNAME MACHINE_NAME
2.2.1.2. 2. Create a host user account.
Ensure the host user name is different from the MACHINE_NAME.
In the rest of the section the host user name is referred to as USER_NAME.
2.2.1.3. 3. Define the mapping between the USER_NAME and HOSTNAME.
Run the following command to configure the Service Principal Mapping:
ktpass -princ HTTP/HOSTNAME@REALM -pass * -mapuser DOMAIN\USER_NAME
Enter the password for the user name when prompted.
Reset the password for the user name as it is a prerequisite for exporting the keytab.
Verify the mapping by running the following command, setspn -L USER_NAME
2.2.1.4. 4. Export the keytab of the user to the server on which EAP JBoss is installed.
Run the following command to export the keytab:
ktab -k service.keytab -a HTTP/HOSTNAME@REALM
This command exports the ticket for the HTTP/HOSTNAME principal to the keytab service.keytab, which is used to configure the host security domain on JBoss EAP 6.
2.2.1.5. 5. Define the principal within the security domain
The principal can be defined or updated in the security domain as follows:
<module-option name="principal">HTTP/HOSTNAME@REALM</module-option>