配置方式:
一、要配置系统环境变量:配置Jaas加载的配置文件路径。
linux下使用
export ACTIVEMQ_OPTS=-Djava.security.auth.login.config=<login.config存储路径>或是在profile文件末尾添加上这样一个导出
windows下
SET ACTIVEMQ_OPTS=%ACTIVEMQ_OPTS% -Djava.security.auth.login.config=<login.config存储路径>
二、配置配置文件
在配置文件broker之间添加下面的配置
- <plugins>
- <!-- Configure authentication; Username, passwords and groups
- 添加jaas认证插件
- activemq-domain 在login.config里面定义,详细见login.config -->
- <jaasAuthenticationPlugin configuration="activemq-domain" />
- <!-- Lets configure a destination based authorization mechanism
- 配置队列用户权限,>表示任意字符 -->
- <authorizationPlugin>
- <map>
- <authorizationMap>
- <authorizationEntries>
- <authorizationEntry queue=">" read="admins" write="admins" admin="admins" />
- <authorizationEntry queue="USERS.>" read="users" write="users" admin="users" />
- <authorizationEntry queue="GUEST.>" read="guests" write="guests,users" admin="guests,users" />
- <authorizationEntry queue="TEST.Q" read="guests" write="guests" />
- <authorizationEntry topic=">" read="admins" write="admins" admin="admins" />
- <authorizationEntry topic="USERS.>" read="users" write="users" admin="users" />
- <authorizationEntry topic="GUEST.>" read="guests" write="guests,users" admin="guests,users" />
- <authorizationEntry topic="ActiveMQ.Advisory.>" read="guests,users" write="guests,users" admin="guests,users"/>
- </authorizationEntries>
- </authorizationMap>
- </map>
- </authorizationPlugin>
- </plugins>
login.config:Jaas插件验证入口
- activemq-domain //与配置文件中jaas plugin配置中的configuration相一致
- {
org.apache.activemq.jaas.PropertiesLoginModule required//加载模块
debug=true //设置调试模式
org.apache.activemq.jaas.properties.user="users.properties"//配置users.properties的相应文件路径
org.apache.activemq.jaas.properties.group="groups.properties";//配置groups.properties的相应文件路径
};
下载连接:login.config
users.properties:配置用户名和密码
- ## ---------------------------------------------------------------------------
## Licensed to the Apache Software Foundation (ASF) under one or more
## contributor license agreements. See the NOTICE file distributed with
## this work for additional information regarding copyright ownership.
## The ASF licenses this file to You under the Apache License, Version 2.0
## (the "License"); you may not use this file except in compliance with
## the License. You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------
#格式user=password -
system=manager
user=password
guest=password
sslclient=CN=localhost, OU=activemq.org, O=activemq.org, L=LA, ST=CA, C=US
下载连接:users.properties
group.properties:配置用户对应的用户组
- ## ---------------------------------------------------------------------------
## Licensed to the Apache Software Foundation (ASF) under one or more
## contributor license agreements. See the NOTICE file distributed with
## this work for additional information regarding copyright ownership.
## The ASF licenses this file to You under the Apache License, Version 2.0
## (the "License"); you may not use this file except in compliance with
## the License. You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------
#格式:用户组=用户1,用户2,...
admins=system,sslclient,client,broker1,broker2
tempDestinationAdmins=system,user,sslclient,client,broker1,broker2
users=system,user,sslclient,client,broker1,broker2
guests=guest
下载连接:group.properties
本文介绍了如何通过Jaas配置ActiveMQ的用户登录验证。涉及系统环境变量配置、Jaas配置文件设置、权限授权以及users和groups属性文件的内容。JaasAuthenticationPlugin用于认证,authorizationPlugin则用于设定不同用户的读写权限。

8738

被折叠的 条评论
为什么被折叠?



