【问题标题】:ActiveMQ Artemis ActiveMQSecurityManager4 verify ClientID/SubscriptionActiveMQ Artemis ActiveMQSecurityManager4 验证 ClientID/Subscription
【发布时间】: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


【解决方案1】:

我认为您想要做的事情已经通过ARTEMIS-592 解决了。您只需将地址和队列名称与broker.xml 中相关security-setting 中的. 字符连接起来。务必将需要隔离的用户分到不同的组中。

明确地说,您不需要实现安全管理器或插件或类似的东西。只需通过配置,您就应该能够处理所需的一切。

【讨论】:

  • 听起来像我需要的,所以它毕竟不是疯狂的 :) 我会在周末看看,因为我不知道在哪里连接它。在 validateUserAndRole 方法上不能,所以我认为它必须在早期阶段完成,所以当它到达 validateUserAndRole 时,已经有地址+队列(clientID+subsName)。
  • 我正在使用 OpenID Connect (OAuth 2.0) 进行身份验证,这就是我创建自定义安全管理器的原因。可能会使用 User Managed Access 2.0 对每个地址进行授权。
  • 另外,您不能通过 JAAS 登录模块与 OpenID Connect 集成吗?
  • 不是和是的。目前在自定义安全管理器上,我使用您的示例进行 OAuth2 客户端凭据流,如果失败,我将委托给 ActiveMQJAASSecurityManager。可以按照medium.com/@joelicious/… 上的建议创建一个 JAAS 登录模块,但自定义安全管理器听起来更好。 ActiveMQSecurityManager4 是完美的,只是错过了作为参数的队列名称,它在调用者方法上可用。也许 ActiveMQSecurityManager5 会拥有它。
  • 您是否在broker.xml 中通过security-settings 配置授权?如果没有,您是否创建了org.apache.activemq.artemis.core.server.SecuritySettingPlugin 的实现?你在开发ActiveMQSecurityManager5吗?
【解决方案2】:

由于https://issues.apache.org/jira/browse/ARTEMIS-2886 的更改,我的初始要求现在可以实现。

【讨论】:

    猜你喜欢
    • 2018-09-03
    • 2022-11-30
    • 2020-07-07
    • 1970-01-01
    • 2020-10-09
    • 2021-10-09
    • 2021-09-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多