ActiveMQ 授权

Cac*_*ing 4 java activemq-classic authorization jaas

如果我想在Apache ActiveMQ上实现JAAS授权,是否必须使用activemq.xml配置文件中的插件?

这种方式真的不好,因为如果我想更改授权,我必须更改 activemq.xml 文件并重新启动服务器才能工作。

有什么方法可以通过更改其他属性文件而不是 activemq.xml 文件来使用 JAAS 身份验证?或者我可以自定义我自己的授权插件吗?

谢谢。

Jak*_*rab 5

每当我设置 ActiveMQ 安全性时,我发现最好使用带有通配符的普通AuthorizationPlugin来表示所涵盖的目的地(这就是为什么使用队列和主题的命名约定非常方便的原因)。这个想法是您定义少数用户组并授予他们访问这些目的地的权限。

从用户名分配组的角色由其中一个身份验证插件处理 - JAAS 插件对于将此信息外部化到 LDAP 目录中的 ActiveMQ 配置之外特别有用。

查看来自 FuseSource的ActiveMQ 安全指南(需要注册)以获取更多信息。

更新 2018-07-02 ActiveMQ 安全指南,现在位于 redhat。


bla*_*ype 5

我发现一些代码片段对于开始讨论这个主题非常有帮助:

http://activemq.2283324.n4.nabble.com/Fully-programmatic-authorization-map-tp2344815.html

这是我最终使用它的方式(可能不是最好的方法):

public class TestAuthorizationPlugin extends AuthorizationPlugin {
Run Code Online (Sandbox Code Playgroud)

然后:

@Override
public Broker installPlugin(Broker broker) {
    List<DestinationMapEntry> entries = new ArrayList<DestinationMapEntry>(); 
    try {
        entries.add(makeTopicAuthorization("groupA.topic", "groupA", "groupA", "groupA"));
        entries.add(makeQueueAuthorization("groupA.queue", "groupA", "groupA", "groupA"));
        entries.add(makeQueueAuthorization("groupB.queue", "groupB", "groupB", "groupB"));
        entries.add(makeTopicAuthorization("ActiveMQ.Advisory.>", "all", "all", "all"));
        AuthorizationMap authMap = new DefaultAuthorizationMap(entries);
        return new AuthorizationBroker(broker, authMap);
    } catch (Exception e) {
        LOGGER.error(e);
    } 

    return new AuthorizationBroker(broker, null);
}
Run Code Online (Sandbox Code Playgroud)

把这个罐子放进去<activemq_home>/lib/

修改activemq.xml:

<plugins>
    <!--  use JAAS to authenticate using the login.config file on the classpath to configure JAAS -->
    <jaasAuthenticationPlugin configuration="activemq" />

    <!-- Authorization control -->
    <bean xmlns="http://www.springframework.org/schema/beans" class="com.blackstrype.activemq.security.TestAuthorizationPlugin"/>
</plugins>
Run Code Online (Sandbox Code Playgroud)

有关 autho 插件开发的更多信息的另一个有用链接:

http://mariuszprzydatek.com/2014/01/04/token-based-authentication-plugin-for-activemq/