Integrating Open DS for use with JBoss
This article looks at how you can use Open LDAP to authenticate users in JBoss. This article takes you through the steps required to secure the JBoss JMX console using OpenDS.
This article looks at how you can use Open LDAP to authenticate users in JBoss. This article takes you through the steps required to secure the JBoss JMX console using OpenDS.
Author
Steve Millidge is the founder of C2B2 and is an expert in the security configuration and integration of JEE application server.
Steve Millidge is the founder of C2B2 and is an expert in the security configuration and integration of JEE application server.
Open DS is an open source LDAPv3 server written in Java and released as open source by Sun. OpenDS can be used to provide a centralised authentication service for JBoss. Out if the box JBoss uses properties files to configure usernames, passwords and roles. This can become unwieldy and difficult to manage in a large JBoss system with multiple JBoss instances.Using OpenDS to storedetails about your users and their roles will provide a central repository which all the JBoss nodes can refer to to authenticate users and retrieve their roles.
Installing OpenDS
Installing OpenDS is straight forward.
- Download the OpenDS zip file from OpenDS.org
- Unzip the installation on your filesystem e.g. C:\opends
- Run setup and a GUI utility starts to walk you through the installation
- Next step set your password for the admin user
In our case we used password
- Create the Directory Base DN appropriate for your server, typically similar to your company domain name
- Review your settings
Once you click Finish the Open LDAP directory server is installed and you can click on the Launch Control Panel button to start creating users and groups.
If you've followed the instructions above click on the "Launch Control Panel" button to fire up the LDAP control panel. Alternatively look in the bin (Linux) or bat (Windows) directory of your OpenDS and run control-panel(.bat). This will start up the LDAP control panel. Once it starts you will be asked to login to OpenDS using the password you entered during the installation.
The you will be presented with the OpenDS control panel.
Within the Control Panel select Manage Entries to bring up the LDAP browser.
The you will be presented with the OpenDS control panel.
Now we need to create two organisational units one to hold the Roles and one to hold the Users.
Now select the base DN as shwon and right click and choose "New Organisational Unit..." and create an Organisational Unit with the Common Name "Roles" and a second Organisational unit with the Common Name "Users".
These Units will hold our roles and users respectively and will be queried by JBoss to authenticate the user and find their roles.
Now we will create the JMX console admin user and Role.
Right click on the "Users" unit in the Manage Entries screen and choose "New User..." from the menu,
Fill in the user details as follows;
The Common Name entry is key as this is the username the user will use to log in to JBoss.
Right click on the "Roles" Unit in the Manage Entries Control Panel. Select "New Group..." from the menu and give the group the name "JBossAdmin" leave all the other entries in the dialog at their default but click on the Add Members... button andselect the admin user we created earlier.
Configure JBoss Authentication
We are now ready to configure the JBoss administration console to use Open DS to obtain user names and passwords.
JBoss has a very configurable security infrastructure which supports many different authentication realms. Out of the box the JBoss security configuration is in the file /conf/login-config.xml.
Open this file and find the entries for the jmx-console. It should look something like by default
this is using the properties files to define the users and groups in JBoss.
We need to change this configuration to use the LDAP Authenticator.
The LDAP authenticator module we want is org.jboss.security.auth.spi.LdapLoginModule as this will retrieve the authentication details from the LDAP server. This module however needs to be told where to look in the LDAP server to find users and roles. This is configured by a number of key module options;
First we need to tell JBoss how to find the user in LDAP from the username entered by the user when prompted. The two options which do this are;
principalDNPrefix which adds a prefix to the username typed by the user. For OpenDS this should be cn=
principalDNSuffic which adds a suffix to the username typed by the user. For our setup above this should be,ou=Users,dc=c2b2,dc=co,dc=uk The exact value will depend on the base dn you entered when installing OpenDS
We also need to tell JBoss where to find the Roles for a user. We do this with the following two module options
rolesCtxDN tells JBoss what branch of the LDAP server to look in for roles. For our configuration above the value of this should be; ou=Roles,dc=c2b2,dc=co,dc=uk
uidAttributeID tells JBoss which attribute within the Group object holds the members. For OpenDS this should be set touniqueMember
roleAttributeID tells JBoss which attribute of the group corresponds to the Role name in this case this should be cn which is short for Common Name
Additional entries need to be set to tell JBoss how to connect to the LDAP server. The completed entry for the jmx-console should look like.
<application-policy name="jmx-console">
<authentication>
<login-module code="org.jboss.security.auth.spi.LdapLoginModule" flag="required">
<module-option name="java.naming.factory.initial">
com.sun.jndi.ldap.LdapCtxFactory
</module-option>
<module-option name="java.naming.provider.url">
ldap://127.0.0.1:389
</module-option>
<module-option name="java.naming.security.authentication">
simple
</module-option>
<module-option name="principalDNPrefix">cn=</module-option>
<module-option name="principalDNSuffix">
,ou=Users,dc=c2b2,dc=co,dc=uk
</module-option>
<module-option name="rolesCtxDN">
ou=Roles,dc=c2b2,dc=co,dc=uk
</module-option>
<module-option name="uidAttributeID">uniqueMember</module-option>
<module-option name="matchOnUserDN">true</module-option>
<module-option name="roleAttributeID">cn</module-option>
<module-option name="roleAttributeIsDN">false</module-option>
</login-module>
</authentication>
</application-policy>
Once you have edited the login-config.xml jmx-console section to look like above. Restart your JBoss server.
You should now be able to browse to the JMX console and login using the credentials configured above.
Conclusions
We have seen how easy it is to secure the JBoss console using OpenDS. Although we have only secured the JMX console the same principals can be used to secure all the different subsystems in JBoss.