Consultor Eletrônico



Kbase 47767: Restringindo o acesso aos consoles administrativos do Jboss
Autor   Luana Leandro Soares - CAT
Acesso   Público
Publicação   8/8/2014
Os consoles ?jmx-console? e ?web-console? são utilizados para tarefas administrativas. Todos os usuários que tenham acesso ao ambiente, podem acessar estes consoles e obter acesso administrativo no processo do JBOSS do produto Datasul11.


Seguem abaixo as instruções para configurar a autenticação para esses dois monitores do JBoss:

1) No arquivo ..\deploy\management\console-mgr.sar\web-console.war\WEB-INF\jboss-web.xml habilitar um domínio de segurança retirando os comentários da tag ?<security-domain>? conforme exemplo abaixo:

<?xml version='1.0' encoding='UTF-8' ?>

<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>

<!-- The war depends on the -->
<depends>jboss.admin:service=PluginManager</depends>
</jboss-web>

2) No arquivo ..\deploy\management\console-mgr.sar\web-console.war\WEB-INF\web.xml habilitar uma restrição de segurança retirando os comentários da tag ?<security-constraint>?, alterando a tag ?<real-name>? para ?jmx-console?, alterando também as tags ?<role-name>? para ?*? conforme exemplo abaixo:

<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>
</web-resource-collection>

<auth-constraint>
<role-name>*</role-name>
</auth-constraint>

</security-constraint>

<login-config>
<auth-method>BASIC</auth-method>
<realm-name>jmx-console</realm-name>
</login-config>

<security-role>
<role-name>*</role-name>
</security-role>

3) No arquivo ..\deploy\jmx-console.war\WEB-INF\jboss-web.xml habilitar um domínio de segurança retirando os comentários da tag ?<security-domain>? conforme exemplo abaixo:

<?xml version='1.0' encoding='UTF-8' ?>

<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>

4) No arquivo ..\deploy\jmx-console.war\WEB-INF\web.xml habilitar uma restrição de segurança retirando os comentários da tag ?<security-constraint>?, alterando a tag ?<real-name>? para ?jmx-console?, alterando também as tags ?<role-name>? para ?*? conforme exemplo abaixo:

<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>
</web-resource-collection>

<auth-constraint>
<role-name>*</role-name>
</auth-constraint>

</security-constraint>

<login-config>
<auth-method>BASIC</auth-method>
<realm-name>jmx-console</realm-name>
</login-config>

<security-role>
<role-name>*</role-name>
</security-role>

5) Criar os arquivos ..\deploy\management\console-mgr.sar\web-console.war\WEB-INF\context.xml e ..\deploy\jmx-console.war\WEB-INF\context.xml conforme exemplo abaixo:

<Context>
<Realm className="org.apache.catalina.realm.JAASRealm"
appName="jmx-console"
allRolesMode="authOnly"
debug="1" />
</Context>

6) Alterar a senha do usuário admin no arquivo ..\conf\props\ jmx-console-users.properties, que vai valer para os dois monitores, conforme exemplo abaixo:

admin=novasenha

7) No arquivo ...\deploy\http-invoker.sar\invoker.war\WEB-INF\web.xml inclua JNDIFactory, EJBInvokerServlet e JMXInvokerServlet no domníno de segurança conforme exemplo abaixo:

<security-constraint>
<web-resource-collection>
<web-resource-name>HttpInvokers</web-resource-name>
<description>An example security config that only allows users with the role HttpInvoker to access the HTTP invoker servlets </description>
<url-pattern>/restricted/*</url-pattern>
<url-pattern>/JNDIFactory/*</url-pattern>
<url-pattern>/EJBInvokerServlet/*</url-pattern>
<url-pattern>/JMXInvokerServlet/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>HttpInvoker</role-name>
</auth-constraint>
</security-constraint>

8) No mesmo arquivo ...\deploy\http-invoker.sar\invoker.war\WEB-INF\web.xml defina o domínio de segurança acrescentando as linhas abaixo:

<jboss-web>
<security-domain>java:/jaas/jmx-console</security-domain>
</jboss-web>

9) Parar a instância JBoss que foram feitos os acertos.

10) Eliminar os diretórios data, farm, log, tmp e work do caminho ...\ServidorAplicacao\jboss-4.2.3.GA\server\instance-xxxx\

11) Iniciar o JBoss e testar o acesso aos monitores.
Referências

51643 - Como desabilitar a página de Status do Tomcat no JBoss