首页 > 解决方案 > 使用自定义 JAAS 访问 Jolokia

问题描述

在 ActiveMQ Artemis 中,当我将requisiteorrequired标志与我的自定义 JAAS 登录模块一起使用时,我无法登录到 Artemis 管理控制台(Jolokia,端口8163)。我在对移动设备进行身份验证的自定义 JAAS 登录模块中有特殊的业务逻辑。但同时我希望有一个管理员用户可以使用一些用户名/密码甚至没有密码登录到 Artemis 管理控制台。为了在 Artemis 中同时拥有自定义和访客登录模块login.config,我必须将自定义 JAAS 模块的安全标志保持为sufficient至少。我该如何处理这种情况?

标签: securityjaasactivemq-artemis

解决方案


Hawtio 使用的安全“领域”是通过hawtio.realm. etc/artemis.profile例如,这是默认值:

JAVA_ARGS=" -XX:+PrintClassHistogram -XX:+UseG1GC -Xms512M -Xmx2G -Dhawtio.realm=activemq  -Dhawtio.offline=true -Dhawtio.role=amq -Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal -Djolokia.policyLocation=${ARTEMIS_INSTANCE_ETC_URI}jolokia-access.xml -Djon.id=amq"

这里hawtio.realm设置为activemq与 default 中的条目匹配login.config,例如:

activemq {
   org.apache.activemq.artemis.spi.core.security.jaas.PropertiesLoginModule sufficient
       debug=false
       reload=true
       org.apache.activemq.jaas.properties.user="artemis-users.properties"
       org.apache.activemq.jaas.properties.role="artemis-roles.properties";

   org.apache.activemq.artemis.spi.core.security.jaas.GuestLoginModule sufficient
       debug=false
       org.apache.activemq.jaas.guest.user="myUser"
       org.apache.activemq.jaas.guest.role="amq";
};

我看不出有什么理由不能专门为 Hawtio 添加新的领域/域login.config,然后更改配置artemis.profile以引用它。这样,您可以根据需要自定义 Hawtio 连接和消息连接的安全性。

此外,值得注意的是,Artemis 最近增加了对每个接受者安全域的支持。您可以在文档中阅读有关此内容的更多信息。


推荐阅读