8.2. JAAS 登录模块配置示例
以下示例显示了配置了属性登录模块和 LDAP 登录模块的 JAAS 登录模块配置。properties 登录模块引用包含 Operator 用来与代理进行身份验证的凭证的默认登录模块。
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";
};
以下示例显示了一个 JAAS 登录模块配置,它在单独的域中有两个属性登录模块。
-
默认属性登录模块位于名为
console的域中,并且具有 Operator 和 AMQ 管理控制台用来与代理进行身份验证的属性文件。 -
activemq域中的登录模块具有新的属性文件,例如,这些文件可以包含用于验证消息传递用户的凭据。
您可能想要创建单独的域,例如,将特定的安全控制应用到包含 Operator 用来与代理进行身份验证的登录模块的域。
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";
};
注意
默认情况下,AMQ Management Console 使用 activemq realm 中的默认属性登录模块进行身份验证。如果在另一个域中配置了默认属性登录模块,如示例所示,您必须在 broker CR 中设置环境变量,将 AMQ 管理控制台配置为使用该域。例如:
spec:
...
env:
- name: JAVA_ARGS_APPEND
value: --Hawtio.realm=console
...
有关在 CR 中设置环境变量的更多信息,请参阅 第 4.9 节 “为代理容器设置环境变量”。