【问题标题】:Tomcat JNDIRealm authenticate and ignore all rolesTomcat JNDIRealm 验证并忽略所有角色
【发布时间】:2014-11-05 19:57:13
【问题描述】:

Tomcat 容器使用 LDAP 对用户进行身份验证

我正在尝试用 LDAP 身份验证替换 Tomcat 的 inMemory 用户数据库。在 conf/server.xml 中进行更改

当用户登录弹出窗口时,我想将用户凭据与 ldap 进行比较。

 <Realm className="org.apache.catalina.realm.JNDIRealm" 
 connectionName="abcusername" 
 connectionPassword="mypassword" 
 connectionURL="ldap://ada.cab.ast.com:389" 
 debug="10" userBase="DC=cab,DC=ast,DC=com" 
 userSearch="(cn={0})" 
 userSubtree="true"/>  

我的 web.xml,如果用户通过身份验证,则没有角色限制

<security-constraint>
    <web-resource-collection>
        <web-resource-name>HTML Manager interface (for humans)</web-resource-name>
        <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>Tomcat Manager Application</realm-name>
</login-config>

当我提供正确的用户名和密码时,我在以下日志中看到用户已通过身份验证但授权失败,我猜想并失败了。 任何帮助表示赞赏。

AuthenticatorBase.register Authenticated 'fkhan002c' with type 'BASIC'
AuthenticatorBase.invoke  Calling accessControl()
hasResourcePermission   Checking roles GenericPrincipal[fkhan002c()]
AuthenticatorBase.invoke  Failed accessControl() test

【问题讨论】:

    标签: tomcat authentication ldap authorization jndi


    【解决方案1】:

    发现问题

    Web-resource-collection 用于 java 资源,因为我试图授权静态内容,正如您所见,我也需要静态内容。

        <security-constraint>
            <web-resource-collection>
                <web-resource-name>Secure contents</web-resource-name>
                <url-pattern>/index.html</url-pattern>
            </web-resource-collection>
            <auth-constraint>
                <role-name>*</role-name>
            </auth-constraint>
        </security-constraint>
    
        <login-config>
            <auth-method>BASIC</auth-method>
            <realm-name>Secure content</realm-name>
        </login-config>
    
    
    <security-role>
           <description>
               This logical role includes all administrative users
           </description>
           <role-name>*</role-name>
       </security-role>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-10
      • 2017-08-12
      • 1970-01-01
      • 2010-11-28
      • 2015-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多