【发布时间】:2020-10-28 00:31:05
【问题描述】:
目前 Artemis 有 ActiveMQSecurityManager4。使用以下方法时,它提供了很多控制:
/**
* Determine whether the given user is valid and whether they have
* the correct role for the given destination address.
*
* This method is called instead of
* {@link ActiveMQSecurityManager#validateUserAndRole(String, String, Set, CheckType)}.
*
* @param user the user
* @param password the user's password
* @param roles the user's roles
* @param checkType which permission to validate
* @param address the address for which to perform authorization
* @param remotingConnection the user's connection
* @param securityDomain the name of the JAAS security domain to use (can be null)
* @return the name of the validated user or null if the user isn't validated
*/
String validateUserAndRole(String user,
String password,
Set<Role> roles,
CheckType checkType,
String address,
RemotingConnection remotingConnection,
String securityDomain);
当客户端连接并尝试创建订阅时,有没有办法知道他的 ClientID/订阅名称是什么? (CheckType=CREATE_DURABLE_QUEUE over address="org.activemq.premium.news")
我想控制允许谁订阅给定地址 (TOPIC) 并保证订阅属于初始(经过身份验证的)订阅者。
编辑 1:
调用方方法有队列(clientID+subs名)但我不认为可以扩展。
/**
* The ActiveMQ Artemis SecurityStore implementation
*/
public class SecurityStoreImpl implements SecurityStore, HierarchicalRepositoryChangeListener {
...
@Override
public void check(final SimpleString address,
final SimpleString queue, //exactly what I was looking for
final CheckType checkType,
final SecurityAuth session) throws Exception {
...
编辑 2:
场景
我有 Bob (user:bob, pass: bob) 和 Alice (user:Alice, pass:Alice),每个人都会创建他们与经纪人的连接来订阅让我们说 address="org.activemq.premium.news ”。到目前为止,我可以阻止其中一个到达该地址,这还不错。现在我希望两者都订阅(每个都有一个队列),但我想确保 Bob 的订阅名为“bob”,而 Alice 的订阅名为“alice”。如果 Alice 先订阅,我不希望它使用“bob”作为订阅名称。也不确定规范是否保证在 Bob 的初始订阅之后,如果他没有连接,Alice 不能使用他的订阅名称来消费他的消息 - 即订阅队列绑定到该用户。
【问题讨论】:
-
您使用什么样的客户端/协议?
-
我正在使用 org.apache.activemq:artemis-jms-client:2.12.0,我认为它使用了 CORE 协议。现在我只需要 JMS 2.0。也可以支持 AMQP 和 STOMP。
-
我真的不明白你想要做什么或为什么(尽管你有解释),但如果你不能通过实施安全管理器来做你想做的事,那么也许你可以做什么你通过broker plugin。
-
我认为安全管理器是我需要的,不知道我应该看看哪个代理插件来完成我想要的。
-
添加了一个场景。也许我的想法很愚蠢,但我希望每个用户(系统)都有特定的订阅名称。正如我所说的“最终的 SimpleString 队列”信息。
标签: activemq-artemis