如何有效地设置权限

时间:2017-11-22 10:34:21

标签: rabbitmq

我有一个Exchange列表(如下所示),我想为所有授予用户WRITE权限,但名称中包含Invoice 的权限。这里以交换列表的摘录为例:

E.BankAccount.Commands
E.BankAccount.Commands.Confirmations
E.BankAccount.Commands.Errors
E.BankAccount.Events
E.Customer.Commands
E.Customer.Commands.Confirmations
E.Customer.Commands.Errors
E.Customer.Events
E.Invoice.Commands
E.Invoice.Commands.Confirmations
E.Invoice.Commands.Errors
E.Payment.Commands
E.Payment.Commands.Confirmations
E.Payment.Commands.Errors
E.Payment.EventsEvents.test

所以我可以写一个这样的正则表达式:

E\.(BankAccount|Customer|Payment)\.[a-zA-Z.]+

这样可行,但由于我有100多种不同的类型,因此输入很多,几乎无法维护。更好的是拥有排除发票的正则表达式。我尝试了几件但没有任何看法,例如。

E\.([a-zA-Z.]+|?!Invoice)\.[a-zA-Z.]+     or
E\.([a-zA-Z.]+|?!(Invoice))\.[a-zA-Z.]+

但这在语法上都是错误的。另一种策略可能是扭转表达的结果,例如:使用

E\.(Invoice)\.[a-zA-Z.]+

然后以某种方式反转整个结果但我无法弄清楚如何!

我不经常使用正则表达式,所以我找不到比我生产环境中不可行的第一个更好的解决方案。

有没有人有更多的经验和解决方案?任何帮助将不胜感激!

0 个答案:

没有答案