8.2. Example JAAS login module configurations
The following example shows a JAAS login module configuration that has both a properties login module and an LDAP login module configured. The properties login module references the default login module that contains the credentials used by the Operator to authenticate with the broker.
activemq {
org.apache.activemq.artemis.spi.core.security.jaas.LDAPLoginModule required
debug=true
initialContextFactory=com.sun.jndi.ldap.LdapCtxFactory
connectionURL="LDAP://localhost:389"
connectionUsername="CN=Administrator,CN=Users,OU=System,DC=example,DC=com"
connectionPassword=redhat.123
connectionProtocol=s
connectionTimeout="5000"
authentication=simple
userBase="dc=example,dc=com"
userSearchMatching="(CN={0})"
userSearchSubtree=true
readTimeout="5000"
roleBase="dc=example,dc=com"
roleName=cn
roleSearchMatching="(member={0})"
roleSearchSubtree=true;
org.apache.activemq.artemis.spi.core.security.jaas.PropertiesLoginModule
reload=true
org.apache.activemq.jaas.properties.user="artemis-users.properties"
org.apache.activemq.jaas.properties.role="artemis-roles.properties"
baseDir="/home/jboss/amq-broker/etc";
};
The following example shows a JAAS login module configuration that has two properties login modules in separate realms.
-
The default properties login module is in a realm named
consoleand has the properties files that are used by the Operator and AMQ Management Console to authenticate with the broker. -
The login module in the
activemqrealm has new properties files, which, for example, could contain the credentials to authenticate users for messaging.
You might want to create separate realms to, for example, apply specific security controls to the realm that contains the login module used by the Operator to authenticate with the broker.
activemq {
org.apache.activemq.artemis.spi.core.security.jaas.PropertiesLoginModule
reload=true
org.apache.activemq.jaas.properties.user="new-users.properties"
org.apache.activemq.jaas.properties.role="new-roles.properties"
};
console {
org.apache.activemq.artemis.spi.core.security.jaas.PropertiesLoginModule
reload=true
org.apache.activemq.jaas.properties.user="artemis-users.properties"
org.apache.activemq.jaas.properties.role="artemis-roles.properties"
baseDir="/home/jboss/amq-broker/etc";
};
By default, AMQ Management Console uses the default properties login module in the activemq realm for authentication. If the default properties login module is configured in another realm, as in the example, you must set an environment variable in the broker CR to configure AMQ Management Console to use that realm. For example:
spec:
...
env:
- name: JAVA_ARGS_APPEND
value: --Hawtio.realm=console
...
For more information about setting environment variables in a CR, see 第 4.9 节 “Setting environment variables for the broker containers”.