具有2种身份验证方法(LDAP+本地)的ActiveMQ Jetty



我目前正在为web控制台的用户(管理员(使用LDAP身份验证配置ActiveMQ jetty web服务器,但我很难同时拥有用于Rest API目的的HashLoginServer。。。

我有办法让这两种身份验证方法在ActiveMQ Jetty上工作吗?

这里是我使用LDAP:的工作配置

<bean id="ldapLoginService" class="org.eclipse.jetty.jaas.JAASLoginService">
<property name="name" value="LDAP realm" />
<property name="loginModuleName" value="LDAPLogin" />
<property name="roleClassNames" value="org.apache.activemq.jaas.GroupPrincipal" />
<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="admin_grp" />
<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_grp" />
<property name="authenticate" value="true" />
</bean>
<bean id="securityConstraintMapping" class="org.eclipse.jetty.security.ConstraintMapping">
<property name="constraint" ref="securityConstraint" />
<property name="pathSpec" value="/api/*,/admin/*,*.jsp" />
</bean>
<bean id="adminSecurityConstraintMapping" class="org.eclipse.jetty.security.ConstraintMapping">
<property name="constraint" ref="adminSecurityConstraint" />
<property name="pathSpec" value="*.action" />
</bean>
<bean id="securityHandler" class="org.eclipse.jetty.security.ConstraintSecurityHandler">
<property name="loginService" ref="ldapLoginService" />
<property name="realmName" value="LdapRealm" />
<property name="identityService" ref="identityService" />
<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> 

和ldap配置:

LDAPLogin {
org.apache.activemq.jaas.LDAPLoginModule required
debug="false"
initialContextFactory=com.sun.jndi.ldap.LdapCtxFactory
connectionURL="{{ ldap_connect_url }}"
connectionUsername="{{ bind_dn }}"
connectionPassword="{{ bind_pw }}"
connectionProtocol=""
authentication=simple
userBase="{{ base_dn }}"
userSearchMatching="{{ ldap_user_search_matching }}"
userSearchSubtree="true"
roleBase="{{ ldap_role_base }}"
roleName="cn"
roleSearchMatching="{{ ldap_role_search_matching }}"
roleSearchSubtree=false
;
};

为什么不将PropertyFileLoginModule添加到JAAS配置文件中?它类似于HashLoginService,但可与JAAS一起使用。您必须更改JAAS配置,使LDAPLoginModule成为sufficient而不是required,并使PropertyFileLoginModule也成为sufficient。这样,如果任何一个登录模块都能成功地对用户进行身份验证。阅读更多关于必需/必需/充分/可选的定义可能会有所帮助。

Jetty 9.x JAAS文档没有提到运行多个身份验证源的能力,但您可以实现自己的自定义JAAS登录模块来支持它。

如果您正在寻找开箱即用的东西,我知道许多人在另一个运行时容器(如ApacheKaraf(中运行ActiveMQ,该容器支持带有多个后端的单个JAAS领域。

最新更新