8.2. JAAS 登录模块配置示例
以下示例显示了一个 JAAS 登录模块配置,它同时配置了属性登录模块和配置了 LDAP 登录模块。属性登录模块引用默认登录模块,其中包含 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 域中的默认属性登录模块进行身份验证。如果在另一个域中配置了默认属性登录模块,如示例所示,您必须在代理 CR 中设置环境变量来配置 AMQ 管理控制台以使用该域。例如:
spec:
...
env:
- name: JAVA_ARGS_APPEND
value: --Hawtio.realm=console
...
有关在 CR 中设置环境变量的更多信息,请参阅 第 4.9 节 “为代理容器设置环境变量”。