`
coach
  • 浏览: 383404 次
  • 性别: Icon_minigender_2
  • 来自: 印度
社区版块
存档分类
最新评论

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/
      弹出提示框,要求输入用户名密码

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics