在使用 PBESecurityDomain 的相互/客户端证书身份验证中忽略 Jboss 应用程序策略

发布于 2024-10-12 05:32:39 字数 3936 浏览 1 评论 0原文

通过以下相互客户端证书,SSL (TLS) 握手适用于休息端点(耶!) - 通过测试和调试进行验证:javax.net 日志记录和调试线鲨。但是...

第一个观察:HTTPServletRequest 和 JAX-RS 注释的 SecurityContext 具有 null 主体信息

第二个观察:篡改包含应用程序策略元素的 login-config.xml 没有效果

简而言之,TLS 有效,但证书的传输请求线程中 HTTPServletRequest 对象的 DN 不会阻止应用程序获取调用者的 ID。有人有什么建议吗?

在 JBoss 6 上:

部署/jbossweb.sar/server.xml:

<Connector protocol="HTTP/1.1" debug="10"
       SSLEnabled="true"
       ...
       secure="true"
       clientAuth="true"
       sslProtocol = "TLS"
       securityDomain="java:/jaas/mydomain"
       SSLImplementation="org.jboss.net.ssl.JBossImplementation" />

部署/jbossweb.sar/META-INF/jboss-beans.xml:

<depends>jboss.security:service=PBESecurityDomain</depends>

部署/security-service.xml:

<?xml version="1.0" encoding="UTF-8"?>
<server>
  <mbean code="org.jboss.security.plugins.JaasSecurityDomain"
    name="jboss.security:service=PBESecurityDomain">
    <constructor>           <arg type="java.lang.String" value="mydomain"/>
    </constructor>
    <attribute name="KeyStoreURL">${jboss.server.home.dir}/mykeystore.jks</attribute>
    <attribute name="KeyStorePass">{CLASS}org.jboss.security.plugins.FilePassword:${jboss.server.home.dir}/mykeystorepass.pbe</attribute>
    <attribute name="TrustStoreURL">${jboss.server.home.dir}/mytruststore.jks</attribute>
    <attribute name="TrustStorePass">password</attribute>
    <attribute name="Salt">abunchofrandomchars</attribute>
    <attribute name="IterationCount">13</attribute>
    <depends>jboss.security:service=JaasSecurityManager</depends>
  </mbean>
</server>

部署/security/security-jboss-beans.xml:

<bean name="XMLLoginConfig" class="org.jboss.security.auth.login.XMLLoginConfig">
   <property name="configResource">login-config.xml</property>
</bean>
<bean name="SecurityConfig" class="org.jboss.security.plugins.SecurityConfig">
   <property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
   <property name="defaultLoginConfig"><inject bean="XMLLoginConfig"/></property>
</bean>

conf/login-config.xml:

  <application-policy name="mydomain">
    <authentication>
       <login-module code="org.jboss.security.auth.spi.BaseCertLoginModule"
          flag = "required">
          <module-option name="password-stacking">useFirstPass</module-option>
          <module-option name="securityDomain">java:/jaas/mydomain</module-option>
          <module-option name="verifier">org.jboss.security.auth.certs.AnyCertVerifier</module-option>
          <module-option name="principalClass">org.jboss.security.auth.certs.SubjectDNMapping</module-option>
       </login-module>
       <login-module code="org.jboss.security.auth.spi.UserRolesLoginModu"
          flag = "required">
          <module-option name="password-stacking">useFirstPass</module-option>
          <module-option name="usersProperties">users.properties</module-option>
          <module-option name="rolesProperties">roles.properties</module-option>
       </login-module>
    </authentication>
 </application-policy>

war/WEB-INF/jboss-web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web PUBLIC
    "-//JBoss//DTD Web Application 2.4//EN"
    "http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
<jboss-web>
    <security-domain>java:/jaas/mydomain</security-domain>
    <context-root>/myapp</context-root>
</jboss-web>

With the following, mutual client cert, SSL (TLS) handshake works for a rest endpoint (yay!) - validated via testing and debugging: javax.net logging & wireshark. But...

1st observation: HTTPServletRequest and JAX-RS annotated SecurityContext has null Principal info

2nd observation: Tampering with the login-config.xml, containing application-policy elements, has no effect

In short, TLS works but the transfer of the cert DN to the HTTPServletRequest object in the request thread does not preventing the application from picking up on the caller's ID. Does anyone have any advice?

On JBoss 6:

deploy/jbossweb.sar/server.xml:

<Connector protocol="HTTP/1.1" debug="10"
       SSLEnabled="true"
       ...
       secure="true"
       clientAuth="true"
       sslProtocol = "TLS"
       securityDomain="java:/jaas/mydomain"
       SSLImplementation="org.jboss.net.ssl.JBossImplementation" />

deploy/jbossweb.sar/META-INF/jboss-beans.xml:

<depends>jboss.security:service=PBESecurityDomain</depends>

deploy/security-service.xml:

<?xml version="1.0" encoding="UTF-8"?>
<server>
  <mbean code="org.jboss.security.plugins.JaasSecurityDomain"
    name="jboss.security:service=PBESecurityDomain">
    <constructor>           <arg type="java.lang.String" value="mydomain"/>
    </constructor>
    <attribute name="KeyStoreURL">${jboss.server.home.dir}/mykeystore.jks</attribute>
    <attribute name="KeyStorePass">{CLASS}org.jboss.security.plugins.FilePassword:${jboss.server.home.dir}/mykeystorepass.pbe</attribute>
    <attribute name="TrustStoreURL">${jboss.server.home.dir}/mytruststore.jks</attribute>
    <attribute name="TrustStorePass">password</attribute>
    <attribute name="Salt">abunchofrandomchars</attribute>
    <attribute name="IterationCount">13</attribute>
    <depends>jboss.security:service=JaasSecurityManager</depends>
  </mbean>
</server>

deploy/security/security-jboss-beans.xml:

<bean name="XMLLoginConfig" class="org.jboss.security.auth.login.XMLLoginConfig">
   <property name="configResource">login-config.xml</property>
</bean>
<bean name="SecurityConfig" class="org.jboss.security.plugins.SecurityConfig">
   <property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
   <property name="defaultLoginConfig"><inject bean="XMLLoginConfig"/></property>
</bean>

conf/login-config.xml:

  <application-policy name="mydomain">
    <authentication>
       <login-module code="org.jboss.security.auth.spi.BaseCertLoginModule"
          flag = "required">
          <module-option name="password-stacking">useFirstPass</module-option>
          <module-option name="securityDomain">java:/jaas/mydomain</module-option>
          <module-option name="verifier">org.jboss.security.auth.certs.AnyCertVerifier</module-option>
          <module-option name="principalClass">org.jboss.security.auth.certs.SubjectDNMapping</module-option>
       </login-module>
       <login-module code="org.jboss.security.auth.spi.UserRolesLoginModu"
          flag = "required">
          <module-option name="password-stacking">useFirstPass</module-option>
          <module-option name="usersProperties">users.properties</module-option>
          <module-option name="rolesProperties">roles.properties</module-option>
       </login-module>
    </authentication>
 </application-policy>

war/WEB-INF/jboss-web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web PUBLIC
    "-//JBoss//DTD Web Application 2.4//EN"
    "http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
<jboss-web>
    <security-domain>java:/jaas/mydomain</security-domain>
    <context-root>/myapp</context-root>
</jboss-web>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

靑春怀旧 2024-10-19 05:32:39

将特殊的 ClientLoginModule 添加到 login-context.xml 以修复 null 主体问题。

<login-module code="org.jboss.security.ClientLoginModule" flag="required"></login-module>

Add the special ClientLoginModule to login-context.xml to fix the null principal issue.

<login-module code="org.jboss.security.ClientLoginModule" flag="required"></login-module>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文