【问题标题】:LDAP authentication for Tomcat - 403 errorTomcat 的 LDAP 身份验证 - 403 错误
【发布时间】:2016-02-16 16:11:20
【问题描述】:

我想使用 LDAP 保护我的 Tomcat 服务器。

首先,我在一个在线 LDAP 测试服务器上尝试它,它的详细信息存在于 http://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/ 中。

我的 tomcat 服务器将所有请求从端口 8080 重定向到端口 8433,然后它要求输入用户名和密码,然后(当我输入正确的数据时)返回 403 错误页面。

有什么问题?

server.xml 中的相关部分:

      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.JNDIRealm" debug="10"
                            connectionURL="ldap://ldap.forumsys.com:389"
                            alternateURL="ldaps://ldap.forumsys.com:636"
                            userBase="dc=example,dc=com"
                            userSearch="(uid={0})"
                            userSubtree="true"
                            userRoleName="l"
                            connectionName="cn=read-only-admin,dc=example,dc=com"
                            connectionPassword="password"
            /> 
  </Realm>

web.xml 中的相关部分:

    <welcome-file-list>
        <welcome-file>main.html</welcome-file>
    </welcome-file-list>

   <security-constraint>
       <web-resource-collection>
           <web-resource-name>Authenticated area</web-resource-name>
           <url-pattern>/main.html</url-pattern>
           <http-method>DELETE</http-method>
           <http-method>GET</http-method>
           <http-method>HEAD</http-method>
           <http-method>POST</http-method>
           <http-method>PUT</http-method>
       </web-resource-collection>

       <auth-constraint>
    <role-name>tomcat</role-name>
           <role-name>Admin</role-name>
           <role-name>Authenticated</role-name>
           <role-name>mathematicians</role-name>
           <role-name>gauss</role-name>
           <role-name>galieleo</role-name>
       </auth-constraint>

   </security-constraint>

   <login-config>
       <auth-method>BASIC</auth-method>
   </login-config>

   <security-role>
       <description>
           This logical role includes all authenticated users
       </description>
    <role-name>tomcat</role-name>
       <role-name>site-users</role-name>
       <role-name>Authenticated</role-name>
       <role-name>mathematicians</role-name>
       <role-name>gauss</role-name>
       <role-name>galieleo</role-name>
   </security-role>  
</web-app>

tomcat-users.xml 中的相关部分:

<tomcat-users xmlns="http://tomcat.apache.org/xml"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
              version="1.0">
  <role rolename="mathematicians"/>
  <role rolename="site-users"/>
  <role rolename="tomcat"/>
  <user username="gauss" roles="site-users,user,tomcat" />
</tomcat-users>

我使用用户名“gauss”和密码“password”

【问题讨论】:

  • 看看this有没有帮助...
  • 我在写我的问题之前看到了那个帖子。但我没有找到任何可以帮助我的回应。
  • 如果您使用的是 LDAP 身份验证,那么您的 tomcat-users.xml 文件完全无关紧要。
  • 您可以使用什么 LDAP 搜索字符串来成功提取任意用户的角色,例如“高斯”?用户角色名真的是l吗?
  • 我写了所有细节。我在 Wireshark 中看到来自 Ldap 服务器的良好响应

标签: java tomcat ldap


【解决方案1】:

什么是 userRoleName="l" 这应该是 LDAP 中用户条目上的 l=locale 属性,并且值必须是 ONE of

<role-name>tomcat</role-name>
<role-name>site-users</role-name>
<role-name>Authenticated</role-name>
<role-name>mathematicians</role-name>
<role-name>gauss</role-name>
<role-name>galieleo</role-name>

如果您想要任何经过身份验证的用户,只需:

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

Try looking here for more information.

【讨论】:

    猜你喜欢
    • 2012-06-27
    • 1970-01-01
    • 2017-07-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多