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.Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
9.6. Enable LDAP Authorization in the Broker
Overview Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
This section explains how to enable LDAP authorization in the broker, so that the broker obtains its authorization data from the directory server.
Compatibility with Apache Karaf principals Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
To avoid unnecessary duplication of user data, this LDAP authorization example reuses the user and role data already created for the Apache Karaf JAAS authentication plug-in (as described in Section 9.3, “Add User Entries to the Directory Server”). This affects the broker's LDAP authorization plug-in configuration, as follows:
- When you create authorization entries in the LDAP server (as described in Section 9.5, “Add Broker Authorization Entries”), you must specify the full DN of the roles that are being authorized. This enables you to specify roles from any location in the LDAP tree (previously, the LDAP authorization plug-in could read roles only from a fixed location under the
ou=ActiveMQ,ou=systemnode). - To enable the use of full DNs when specifying roles, you must set the
legacyGroupMappingproperty tofalsein the LDAP authorization plug-in (the default istrue). - Because the Apache Karaf roles are a different type than the roles natively supported by the LDAP authorization plug-in, you must also specify the type of the Karaf roles, by setting the
groupClassproperty.
Enable broker LDAP authorization in a standalone OSGi container Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Perform the following steps to enable broker LDAP authorization in a standalone OSGi container:
- Shut down the JBoss A-MQ container, if it is currently running. In the console window, enter the following command:
JBossA-MQ:karaf@root> shutdown
JBossA-MQ:karaf@root> shutdownCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Make a backup copy of the broker configuration file,
InstallDir/etc/activemq.xml. - Replace the LDAP authorization plug-in in the broker configuration. Open the broker configuration file,
InstallDir/etc/activemq.xml, with a text editor and replace the defaultauthorizationMapelement by thecachedLDAPAuthorizationMapelement, as follows:Copy to Clipboard Copied! Toggle word wrap Toggle overflow You must customize the following settings in theactivemq.xmlfile:- connectionURL
- Set this URL to the actual location of your directory server instance. Normally, this URL has the format,
ldap://Hostname:Port. For example, the default port for the 389 Directory Server is IP port389. - connectionUsername
- Specifies the username that is used to authenticate the connection to the directory server. For 389 Directory Server, the default is usually
cn=Directory Manager. - connectionPassword
- Specifies the password part of the credentials for connecting to the directory server.
- queueSearchBase
- Replace
YourDomainwith the name of the root node on your directory server. - topicSearchBase
- Replace
YourDomainwith the name of the root node on your directory server. - tempSearchBase
- Replace
YourDomainwith the name of the root node on your directory server.
NoteFor more details about the options available on thecachedLDAPAuthorizationMapelement, see Section 8.2, “Cached LDAP Authorization Plug-In”. - Ensure that the X.500 directory server is running. If necessary, manually restart the X.500 directory server—see Section 9.2, “Set-up a Directory Server and Console”. If the server is not running, all broker connections will fail.
- Restart the JBoss A-MQ container. Open a new command prompt and start the broker by entering the following command:
amq
amqCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Enable broker LDAP authorization in a Fabric Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Perform the following steps to enable broker LDAP authorization in a fabric:
- Create a new version of the Fabric profile data, by entering the following console command:
JBossFuse:karaf@root> version-create Created version: 1.2 as copy of: 1.1
JBossFuse:karaf@root> version-create Created version: 1.2 as copy of: 1.1Copy to Clipboard Copied! Toggle word wrap Toggle overflow Where we have assumed that the current version is1.1.NoteIn effect, this command creates a new branch named1.2in the Git repository underlying the ZooKeeper registry. - Edit the
broker.xmlresource in version1.2of themq-baseprofile, as follows:JBossFuse:karaf@root> profile-edit --resource broker.xml mq-base 1.2
JBossFuse:karaf@root> profile-edit --resource broker.xml mq-base 1.2Copy to Clipboard Copied! Toggle word wrap Toggle overflow The built-in profile editor opens automatically, which you can use to edit the contents of thebroker.xmlresource. - Add the LDAP authorization plug-in to the broker configuration,
broker.xml. Using the editor that opened in the previous step, add the defaultauthorizationPluginelement as a child of thepluginselement, as follows:Copy to Clipboard Copied! Toggle word wrap Toggle overflow You must customize the following settings in thebroker.xmlresource:- connectionURL
- Set this URL to the actual location of your directory server instance. Normally, this URL has the format,
ldap://Hostname:Port. For example, the default port for the 389 Directory Server is IP port389. - connectionUsername
- Specifies the username that is used to authenticate the connection to the directory server. For 389 Directory Server, the default is usually
cn=Directory Manager. - connectionPassword
- Specifies the password part of the credentials for connecting to the directory server.
- queueSearchBase
- Replace
YourDomainwith the name of the root node on your directory server. - topicSearchBase
- Replace
YourDomainwith the name of the root node on your directory server. - tempSearchBase
- Replace
YourDomainwith the name of the root node on your directory server.
NoteFor more details about the options available on thecachedLDAPAuthorizationMapelement, see Section 8.2, “Cached LDAP Authorization Plug-In”. - Save and close the
broker.xmlresource by typing Ctrl-S and Ctrl-X. - To check that you have edited the
broker.xmlresource correctly, you can print out the 1.2 version of themq-baseprofile and its resources using the following console command:JBossFuse:karaf@root> profile-display --version 1.2 -r mq-base
JBossFuse:karaf@root> profile-display --version 1.2 -r mq-baseCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Ensure that the X.500 directory server is running. If necessary, manually restart the X.500 directory server—see Section 9.2, “Set-up a Directory Server and Console”. If the server is not running, all broker connections will fail.
- The broker LDAP authorization is not activated, until you upgrade a container to use the new version,
1.2, of themq-baseprofile. For example, to activate broker LDAP authorization on therootcontainer, enter the following console command (assuming a broker profile is already deployed on therootcontainer):JBossFuse:karaf@root> container-upgrade 1.2 root
JBossFuse:karaf@root> container-upgrade 1.2 rootCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Install the Apache ActiveMQ kit Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
For testing purposes, it is useful to install the Apache ActiveMQ example producer and consumer clients. These example clients are not provided directly in the JBoss A-MQ package. But you can obtain the sample clients by installing the Apache ActiveMQ kit,
apache-activemq-5.11.0.redhat-621084-bin.zip, provided in the extras/ directory of the JBoss A-MQ installation.
Install the Apache ActiveMQ kit as follows:
- Find the Apache ActiveMQ kit at the following location:
InstallDir/extras/apache-activemq-5.11.0.redhat-621084-bin.zip
InstallDir/extras/apache-activemq-5.11.0.redhat-621084-bin.zipCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Using a suitable archive utility on your platform, unzip the
apache-activemq-5.11.0.redhat-621084-bin.zipfile and extract it to a convenient location,ActiveMQInstallDir.
Test the new configuration Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
To test the new configuration, run the example consumer and producer clients as follows:
- Run the consumer client with the
jdoeuser credentials. Open a new command prompt, change directory toActiveMQInstallDir/examples/openwire/swissarmy, and enter the following Ant command:ant consumer -Durl=tcp://localhost:61616 -Dmax=100 -Duser=jdoe -Dpassword=secret
ant consumer -Durl=tcp://localhost:61616 -Dmax=100 -Duser=jdoe -Dpassword=secretCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf testing against a Fabric container, you might need to change the broker port to61617. - Run the producer client with the
jdoeuser credentials. Open a new command prompt, change directory toActiveMQInstallDir/examples/openwire/swissarmy, and enter the following Ant command:ant producer -Durl=tcp://localhost:61616 -Dmax=100 -Duser=jdoe -Dpassword=secret
ant producer -Durl=tcp://localhost:61616 -Dmax=100 -Duser=jdoe -Dpassword=secretCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Run a negative test, to demonstrate that unauthorized users are blocked from accessing the broker queues.Run the consumer client with the
janedoeuser credentials. Open a new command prompt, change directory toActiveMQInstallDir/examples/openwire/swissarmy, and enter the following Ant command:ant consumer -Durl=tcp://localhost:61616 -Dmax=100 -Duser=janedoe -Dpassword=secret
ant consumer -Durl=tcp://localhost:61616 -Dmax=100 -Duser=janedoe -Dpassword=secretCopy to Clipboard Copied! Toggle word wrap Toggle overflow This time, the consumer client fails, becausejanedoedoes not belong to theAdministratorgroup.