AmazonMQ ActiveMQ问题,权限过于严格



我有一个AmazonMQ (ActiveMQ 5.17.1)的设置,在我的地形中定义了一个用户:

user {
username = "myUser"
password = "somethingSecret"
console_access = false
}

和ActiveMQ配置没有任何授权:我的客户端能够连接没有问题。

现在我想为其他一些用户设置authorizationMap,并赋予用户myUser对所有队列和主题的管理权限。

这是我的authorizationMap的样子:

<authorizationPlugin>
<map>
<authorizationMap>
<authorizationEntries>
<authorizationEntry queue="SYS1.IN.>" read="system1"/>
<authorizationEntry queue="SYS2.IN>" read="system2"/>
<authorizationEntry queue="SYS2.OUT>" write="system2"/>
<!-- few other queues / permissions -->
<!-- taken from https://docs.aws.amazon.com/amazon-mq/latest/developer-guide/child-element-details.html#authorizationEntry -->
<authorizationEntry admin="admins,activemq-webconsole" read="admins,users,activemq-webconsole" write="admins,activemq-webconsole" queue=">"/>
<authorizationEntry admin="admins,activemq-webconsole" read="admins,users,activemq-webconsole" write="admins,activemq-webconsole" topic=">"/>
</authorizationEntries>
</authorizationMap>
</map>
</authorizationPlugin>

和我也添加了myUSer到admin组在terraform:

user {
username = "myUser"
password = "somethingSecret"
groups = ["admins"]
}

但是通过这种设置,我在AWS日志(以及客户端)中看到一个错误,上面写着:

... User myUser doesn't have permission to write in topic `ActiveMQ.Advisory.Connection` ...

我试图在authorizationMap中添加以下条目(保留上面现有的条目):

<authorizationEntry topic="ActiveMQ.Advisory.>" read="admins,activemq-webconsole" write="admins,activemq-webconsole" admin="admins,activemq-webconsole"/>

但是错误还是一样的

请注意,当我试图从控制台发送队列中的消息时(使用另一个用户,其中console_access = true)会发生错误,但我可以创建新的队列。

注意,我在每次配置更改之间强制重新启动代理,但上面的错误仍然存在。

我发现我的地形文件有两个问题:

首先我必须添加一个authentication_strategy:

authentication_strategy = "simple"

但是单靠这个还是不行

从控制台我看到我的代理没有引用最新的配置。

然后,我必须显式地在我的配置中添加revision行,像这样:

configuration {
id = aws_mq_configuration.conf-amq-area51-dev.id
revision = aws_mq_configuration.conf-amq-area51-dev.latest_revision
}

明确引用最新版本,因为我做了一个(错误的)假设,即不引用修订将隐含地采用最新版本。

经过这两次修改后,我可以正确地使用我的用户,控制台管理也可以正常工作。

在我的初始配置中还缺少另一个重要的点:分配给每个用户的组。如果我想分配像问题中那样的授权:

<authorizationEntry queue="SYS1.IN.>" read="system1"/>
<authorizationEntry queue="SYS2.IN>" read="system2"/>
<authorizationEntry queue="SYS2.OUT>" write="system2"/>

system1system2表示组而不是用户,因为在ActiveMQ中authorizationEntry总是引用一个组而不是单个用户。解决方法是使用与用户相同的名称命名(并分配)组(有点像Linux)。

在Terraform中,你可以这样声明它们:

user {
username = "system1"
password = "somethingSecretPa$$01"
console_access = false
groups = ["system1"]
}
user {
username = "system2"
password = "somethingSecretPa$$02"
console_access = false
groups = ["system2"]
}

最新更新