Red Hat AMQ 6
As of February 2025, Red Hat is no longer supporting Red Hat AMQ 6. If you are using AMQ 6, please upgrade: Migrating to AMQ 7.8.4. Enable LDAP Authentication in the OSGi Container
Overview Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
In this part of the tutorial you will configure an LDAP realm in the OSGi container. The new realm overrides the default karaf realm, so that the container authenticates credentials based on user entries stored in the X.500 directory server.
Procedure for standalone OSGi container Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
To enable LDAP authentication in a standalone OSGi container:
- Ensure that the X.500 directory server is running.
- Start Red Hat JBoss A-MQ by entering the following command in a terminal window:
amq
amqCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Create a Blueprint configuration file called
ldap-module.xml. - Copy Example 8.1, “JAAS Realm for Standalone” into
ldap-module.xml.Example 8.1. JAAS Realm for Standalone
Copy to Clipboard Copied! Toggle word wrap Toggle overflow This login module creates a JAAS realm calledkaraf, which is the same name as the default JAAS realm used by Red Hat JBoss A-MQ. By redefining this realm with arankattribute value greater than0, it overrides the standardkarafrealm which has the rank0. For more information on configuring a JAAS realm see Section 2.1.2, “Defining JAAS Realms”.For a detailed description of configuring JBoss A-MQ to use LDAP see Section 2.2, “Enabling LDAP Authentication”.ImportantWhen setting the JAAS properties above, do not enclose the property values in double quotes.TipIf you use OpenLDAP, the syntax of the role filter is(member:=uid=%u). - To deploy the new LDAP module, copy the
ldap-module.xmlinto the JBoss A-MQdeploy/directory.The LDAP module is automatically activated.
Procedure for a Fabric Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
To enable LDAP authentication in a Fabric (affecting all of the containers in the current fabric):
- Ensure that the X.500 directory server is running.
- If your local Fabric container is not already running, start it now, by entering the following command in a terminal window:
./amq
./amqCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf the Fabric container you want to connect to is running on a remote host, you can connect to it using theclientcommand-line utility in theInstallDir/bindirectory. - Create a new version of the Fabric profile data, by entering the following console command:
JBossFuse:karaf@root> version-create Created version: 1.1 as copy of: 1.0
JBossFuse:karaf@root> version-create Created version: 1.1 as copy of: 1.0Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIn effect, this command creates a new branch named1.1in the Git repository underlying the ZooKeeper registry. - Create the new profile resource,
ldap-module.xml(a Blueprint configuration file), in version1.1of thedefaultprofile, as follows:JBossFuse:karaf@root> profile-edit --resource ldap-module.xml default 1.1
JBossFuse:karaf@root> profile-edit --resource ldap-module.xml default 1.1Copy to Clipboard Copied! Toggle word wrap Toggle overflow The built-in profile editor opens automatically, which you can use to edit the contents of theldap-module.xmlresource. - Copy Example 8.2, “JAAS Realm for Fabric” into the
ldap-module.xmlresource, customizing the value of therankattribute and theconnection.urlproperty, as necessary.Example 8.2. JAAS Realm for Fabric
Copy to Clipboard Copied! Toggle word wrap Toggle overflow WhereLDAPHostis the name of the host where the LDAP server is running. You must be sure to use a hostname that is accessible to all of the containers in the fabric (for example, you cannot uselocalhostas the hostname here).Save and close theldap-module.xmlresource by typing Ctrl-S and Ctrl-X.This login module creates a JAAS realm calledkaraf, which is the same name as the default JAAS realm used by Red Hat JBoss A-MQ. By redefining this realm with arankof2, it overrides all of the previously installedkarafrealms. For more information on configuring a JAAS realm see Section 2.1.2, “Defining JAAS Realms”.For a detailed description of configuring JBoss A-MQ to use LDAP see Section 2.2, “Enabling LDAP Authentication”.ImportantPay particular attention to the value of therankto ensure that it is higher than all previously installedkarafrealms. If therankis not sufficiently high, the new realm will not be used by the fabric.ImportantWhen setting the JAAS properties above, do not enclose the property values in double quotes.TipIf you use OpenLDAP, the syntax of the role filter is(member:=uid=%u). - Edit the agent properties of version 1.1 of the
defaultprofile, adding an instruction to deploy the Blueprint resource file defined in the previous step. Enter the following console command:JBossFuse:karaf@root> profile-edit default 1.1
JBossFuse:karaf@root> profile-edit default 1.1Copy to Clipboard Copied! Toggle word wrap Toggle overflow The built-in profile editor opens automatically. Add the following line to the agent properties:bundle.ldap-realm=blueprint:profile:ldap-module.xml
bundle.ldap-realm=blueprint:profile:ldap-module.xmlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Save and close the agent properties by typing Ctrl-S and Ctrl-X. - The new LDAP realm is not activated, until you upgrade a container to use the new version,
1.1. To activate LDAP on a single container (for example, on a container calledroot), enter the following console command:JBossFuse:karaf@root> container-upgrade 1.1 root
JBossFuse:karaf@root> container-upgrade 1.1 rootCopy to Clipboard Copied! Toggle word wrap Toggle overflow To activate LDAP on all containers in the fabric, enter the following console command:JBossFuse:karaf@root> container-upgrade --all 1.1
JBossFuse:karaf@root> container-upgrade --all 1.1Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantIt is advisable to upgrade just a single container initially, to make sure that everything is working properly. This is particularly important, if you have only remote access to the fabric: if you upgrade all of the containers at once, you might not be able to reconnect to the fabric.
Test the LDAP authentication Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Test the new LDAP realm by connecting to the running container using the Red Hat JBoss A-MQ
client utility, as follows:
- Open a new command prompt.
- change directory to the JBoss A-MQ
InstallDir/bindirectory. - Enter the following command to log on to the running container instance using the identity
janedoe:client -u janedoe -p secret
client -u janedoe -p secretCopy to Clipboard Copied! Toggle word wrap Toggle overflow You should receive the following message:Authentication failure
Authentication failureCopy to Clipboard Copied! Toggle word wrap Toggle overflow This fails becausejanedoedoes not have theadminrole which is required for using the remote console. - Enter the following command to log on to the running container instance using the identity
jdoe:client -u jdoe -p secret
client -u jdoe -p secretCopy to Clipboard Copied! Toggle word wrap Toggle overflow You should successfully log into the container's remote console becausejdoedoes have theadminrole. - Log off the remote console by entering the logout command.