jboss用户验证

当我们配置好Jboss后,任何人都可以访问http://localhost:8080/jmx-console/,这也带来了很大的安全隐患,接下来配置认证
1、修改安装目录下的server/default/deploy/jmx-console.war/WEB-INF/jboss-web.xml
找到:
<jboss-web>
<!-- Uncomment the security-domain to enable security. You will
need to edit the htmladaptor login configuration to setup the
login modules used to authentication users.
<security-domain>java:/jaas/jmx-console</security-domain> -->
</jboss-web>
删除注释最后如下:
<jboss-web>
<security-domain>java:/jaas/jmx-console</security-domain>
</jboss-web>
//启用安全jmx-console认证,那么要使用什么安全策略呢
2、修改和jboss-web.xml同一目录的web.xml
找到如下文字:
<!-- A security constraint that restricts access to the HTML JMX console
to users with the role JBossAdmin. Edit the roles to what you want and
uncomment the WEB-INF/jboss-web.xml/security-domain element to enable
secured access to the HTML JMX console.
<security-constraint>
<web-resource-collection>
<web-resource-name>HtmlAdaptor</web-resource-name>
<description>An example security config that only allows users with the
role JBossAdmin to access the HTML JMX console web application
</description>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>JBossAdmin</role-name>
</auth-constraint>
</security-constraint> -->
去掉注释,结果改成如下:
<security-constraint>
<web-resource-collection>
<web-resource-name>HtmlAdaptor</web-resource-name>
<description>An example security config that only allows users with the
role JBossAdmin to access the HTML JMX console web application
</description>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>JBossAdmin</role-name>
</auth-constraint>
</security-constraint>
//要求登录的用户必须属于JbossAdmin属于这个角色。
3、打开配置文件default/conf/login-config.xml找出用户名密码存在哪个文件
找到如下:
<application-policy name="jmx-console">
<authentication>
<login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"
flag="required">
<module-option name="usersProperties">props/jmx-console-users.properties</module-option>
<module-option name="rolesProperties">props/jmx-console-roles.properties</module-option>
</login-module>
</authentication>
</application-policy>
从以上配置我们可以知道。
用户属性(usersProperties)文件是当前文件目录下的props/jmx-console-users.properties
角色属性(rolesProperties)文件在props/jmx-console-roles.properties

4、添加用户,并为用户设置角色
打开jmx-console-users.properties文件。我们可以看到如下内容:
# A sample users.properties file for use with the UsersRolesLoginModule
admin=admin
接下来我们添加用户密码,输入
jboss=123456
注:jboss是用户名,123456是密码
打开jmx-console-roles.properties文件。我们可以看到如下内容:
# A sample roles.properties file for use with the UsersRolesLoginModule
admin=JBossAdmin,HttpInvoker
接下来我们设置jboss的角色,输入
jboss=JbossAdmin
注:jboss是用户,JbossAdmin是它的角色
5、重启测试。
输入:http://localhost:8080/jmx-console/
弹出提示框,要求输入用户名密码
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值