trouble setting up LDAP integration with ActiveMQ

2019-08-20 07:07发布

I have read every page I can find on this, and I just am not getting something. I am but a simple farmer (sysadmin), and I am running out hair to pull out.

What I did: On a Centos7 box, I installed apache-activemq-5.15.8 by downloading the latest tarball, and expanding it. I set up a service file and a few other niceties, and the service will run, and I could log into the admin page with the default creds. Being a masochist, I deiced to make it 'easy' for the users of this app by configuring LDAP integration for the admin page... and that's when the fight started.

I found some conflicting information on the Apache pages. Namely: http://activemq.apache.org/security.html and http://activemq.apache.org/cached-ldap-authorization-module.html

But I found some pages that seem more helpful, like: https://bacedifo.blogspot.com/2013/06/securing-activemq-580-web-console-using.html and ActiveMQ Web console using LDAP Active Directory authentication

The error I am getting is basically the same as from this question: Configuring Activemq web console to use LDAP for authorization and authentication but the answer does not give me enough to go on... I might need it one and two syllable words.

The admin page shows this error: enter image description here

The activemq.log file shows this error:

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]

My conf changes are: downloaded jetty-jaas-9.4.15.v20190215.jar and ldaptive-1.2.4.jar and copied them to $ACTIVEMQ_HOME/lib

changed $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";
};

And I configured $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>

If you made it this far, I thank you very much!

1条回答
再贱就再见
2楼-- · 2019-08-20 07:31

Alright, I found it!

So I worked with a java dev that works here, and he said what is likely obvious to many of you: Some necessary classes are not available in the classpath. In some testing and digging, I corrected this by expanding on the instructions found here: ActiveMQ Web console using LDAP Active Directory authentication The answer there says to copy 2 files into the /lib dir, but that does not include dependencies. I found a pack of all dependencies, (checked them on virus total) and copied them all to /lib. While this did not fix every issue, this did fix this error. The bundle of jars I found is here:
https://jar-download.com/artifacts/org.eclipse.jetty/jetty-jaas/9.2.25.v20180606/source-code

查看更多
登录 后发表回答