首页 > 解决方案 > 在设置 LDAP 与 ActiveMQ 集成时遇到问题(在 centos7 上)管理页面

问题描述

我已经阅读了我能找到的每一页,但我没有得到任何东西。我只是一个简单的农民(系统管理员),我的头发快要拔出来了。

我做了什么:在 Centos7 机器上,我通过下载最新的 tarball 并展开它来安装 apache-activemq-5.15.8。我设置了一个服务文件和其他一些细节,该服务将运行,我可以使用默认凭据登录管理页面。作为一个受虐狂,我决定通过为管理页面配置 LDAP 集成来让这个应用程序的用户“轻松”......这就是战斗开始的时候。

我在 Apache 页面上发现了一些相互矛盾的信息。即: http ://activemq.apache.org/security.html和http://activemq.apache.org/cached-ldap-authorization-module.html

但我发现一些页面似乎更有帮助,例如: https ://bacedifo.blogspot.com/2013/06/securing-activemq-580-web-console-using.html和使用 LDAP Active Directory 身份验证的 ActiveMQ Web 控制台

我得到的错误与这个问题基本相同: Configuring Activemq web console to use LDAP for authorization and authentication 但答案并没有给我足够的继续......我可能需要一个和两个音节词。

管理页面显示此错误: 在此处输入图像描述

activemq.log 文件显示此错误:

java.lang.AbstractMethodError: org.eclipse.jetty.jaas.JAASLoginService.login(Ljava/lang/String;Ljava/lang/Object;)Lorg/eclipse/jetty/server/UserIdentity;
        at org.eclipse.jetty.security.authentication.LoginAuthenticator.login(LoginAuthenticator.java:61)[jetty-all-9.2.25.v20180606.jar:9.2.25.v20180606]
        at org.eclipse.jetty.security.authentication.BasicAuthenticator.validateRequest(BasicAuthenticator.java:92)[jetty-all-9.2.25.v20180606.jar:9.2.25.v20180606]
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:512)[jetty-all-9.2.25.v20180606.jar:9.2.25.v20180606]
        at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)[jetty-all-9.2.25.v20180606.jar:9.2.25.v20180606]
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)[jetty-all-9.2.25.v20180606.jar:9.2.25.v20180606]
        at org.eclipse.jetty.server.Server.handle(Server.java:499)[jetty-all-9.2.25.v20180606.jar:9.2.25.v20180606]
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)[jetty-all-9.2.25.v20180606.jar:9.2.25.v20180606]
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:258)[jetty-all-9.2.25.v20180606.jar:9.2.25.v20180606]
        at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)[jetty-all-9.2.25.v20180606.jar:9.2.25.v20180606]
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)[jetty-all-9.2.25.v20180606.jar:9.2.25.v20180606]
        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)[jetty-all-9.2.25.v20180606.jar:9.2.25.v20180606]
        at java.lang.Thread.run(Thread.java:748)[:1.8.0_201]

我的 conf 更改是:下载 jetty-jaas-9.4.15.v20190215.jar 和 ldaptive-1.2.4.jar 并将它们复制到 $ACTIVEMQ_HOME/lib

更改了 $ACTIVEMQ_HOME/conf/login.config:

activemq-local {
    org.apache.activemq.jaas.PropertiesLoginModule required
        debug=true
        org.apache.activemq.jaas.properties.user="org/apache/activemq/security/users.properties"
        org.apache.activemq.jaas.properties.group="org/apache/activemq/security/groups.properties";
};

contosoRealm {
    org.ldaptive.jaas.LdapLoginModule required
        debug=true
        storePass="true"
        ldapUrl="ldap://dc01.contoso.com:389"
        bindDn="cn=SVC ActiveMQ,ou=Service Accounts,dc=contoso,dc=com"
        baseDn="OU=User Accounts,DC=contoso,DC=com"
        bindCredential="contos0_win5"
        useStartTLS="false"
        userFilter="(sAMAccountName={user})";
   org.ldaptive.jaas.LdapRoleAuthorizationModule required
        useFirstPass="true"
        ldapUrl="ldap://dc01.contoso.com:389"
        bindDn="cn=SVC ActiveMQ,ou=Service Accounts,dc=contoso,dc=com"
        baseDn="OU=Security Groups,OU=Groups,DC=contoso,DC=com"
        bindCredential="contos0_win5"
        roleFilter="(&(cn=activemq_admins)(member={user}))"
        useStartTLS="false"
        defaultRole="admins"
        roleAttribute="cn";
};

我配置了 $ACTIVEMQ_HOME/conf/jetty.xml

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">


    <bean id="securityLDAPLoginService" class="org.eclipse.jetty.jaas.JAASLoginService">
        <property name="name" value="contosoRealm" />
        <property name="LoginModuleName" value="contosoRealm" />
        <property name="roleClassNames" value="org.eclipse.jetty.jaas.JAASRole" />
        <property name="identityService" ref="identityService" />
    </bean>

    <bean id="identityService" class="org.eclipse.jetty.security.DefaultIdentityService"/>

    <bean id="securityConstraint" class="org.eclipse.jetty.util.security.Constraint">
        <property name="name" value="BASIC" />
        <property name="roles" value="admins,ActiveMQ Admins" />
        <!-- set authenticate=false to disable login -->
        <property name="authenticate" value="true" />
    </bean>

    <bean id="adminSecurityConstraint" class="org.eclipse.jetty.util.security.Constraint">
        <property name="name" value="BASIC" />
        <property name="roles" value="admin,ActiveMQ Admins" />
         <!-- set authenticate=false to disable login -->
        <property name="authenticate" value="true" />
    </bean>
....
....
    <bean id="securityHandler" class="org.eclipse.jetty.security.ConstraintSecurityHandler">
        <property name="loginService" ref="securityLDAPLoginService" />
        <property name="identityService" ref="identityService" />
        <property name="realmName" value="contosoRealm" />
        <property name="authenticator">
            <bean class="org.eclipse.jetty.security.authentication.BasicAuthenticator" />
        </property>
        <property name="constraintMappings">
            <list>
                <ref bean="adminSecurityConstraintMapping" />
                <ref bean="securityConstraintMapping" />
            </list>
        </property>
        <property name="handler" ref="secHandlerCollection" />
    </bean>

如果你做到了这一步,我非常感谢你!

标签: ldapjettyactivemq

解决方案


好吧,我找到了!

所以我和一个在这里工作的 java 开发人员一起工作,他说了对你们中的许多人来说可能显而易见的事情:类路径中没有一些必要的类。在一些测试和挖掘中,我通过扩展此处找到的说明来纠正此问题: 使用 LDAP Active Directory 身份验证的 ActiveMQ Web 控制台 那里的答案说将 2 个文件复制到 /lib 目录中,但这不包括依赖项。我找到了所有依赖项的包,(检查了病毒总数)并将它们全部复制到 /lib。虽然这并没有解决所有问题,但这确实解决了这个错误。我找到的罐子包在这里:
https ://jar-download.com/artifacts/org.eclipse.jetty/jetty-jaas/9.2.25.v20180606/source-code


推荐阅读