有人知道如何通过definitions.json配置文件为用户提供额外的主题权限(例如amq.topic)吗? (我知道可以通过管理控制台进行设置,但我不想手动设置。)
我已经尝试过以下操作,但没有授予任何额外的主题权限:
{
"user": "guest",
"vhost": "/",
"configure": ".*",
"write": ".*",
"read": ".*"
},
{
"user": "guest",
"vhost": "/",
"configure": "amq.topic",
"write": ".*",
"read": ".*"
},
您需要添加 topic_permissions 部分,其中包含您想要的配置:
"topic_permissions": [
{
"user": "guest",
"vhost": "/",
"exchange": "amq.topic",
"write": "[^.]+\\.sample\\.[^.]+",
"read": ""
}
]
为了弄清楚这些事情,我通常在管理界面中手动创建它们,然后导出定义以查看它是如何“翻译”的。
参见(填写用户/通行证)中的
topic_permissions
部分:
curl --silent --user yourusername:yourpass --header "Content-type: application/json" http://127.0.0.1:15672/api/definitions | jq . | tee config.json
或者不交换的例子:
"topic_permissions": [
{
"user": "yourusername",
"vhost": "/",
"exchange": "",
"write": ".*",
"read": ".*"
}
]