gpt4 book ai didi

Tomcat JNDIRealm 验证并忽略所有角色

转载 作者:行者123 更新时间:2023-11-28 21:59:55 25 4
gpt4 key购买 nike

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

最佳答案

发现问题

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>

关于Tomcat JNDIRealm 验证并忽略所有角色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26765948/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com