如何解决Tomcat 8.5 将 ldap 组映射到安全角色不起作用
我正在尝试将应用程序的安全角色映射到 tomcat 8.5.13 中的 ldap 组。为了测试这一点,我正在尝试示例受保护的 tomcat 应用程序。 根据我的发现,我必须将这样的块添加到应用程序的 WEB-INF/web.xml 中:
<!-- Security roles referenced by this web application -->
<security-role>
<role-name>role1</role-name>
</security-role>
<security-role>
<role-name>tomcat</role-name>
</security-role>
<security-role-ref>
<role-name>CN=LDAP_GROUP,OU=Groups,DC=<sub_dc>,DC=<dc>,DC=com</role-name>
<role-link>tomcat</role-link>
</security-role-ref>
“tomcat”和“role1”被配置为示例应用程序的身份验证约束中的角色。
这是我在 $TOMCAT_HOME/conf/server.xml 中的 JNDI 配置:
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<Realm className="org.apache.catalina.realm.JNDIRealm"
connectionURL="ldap://<ldap_host>:3268"
connectionName="<ldap_bind_dn>"
connectionPassword="<ldap_pw>"
connectionTimeout="3000"
referrals="follow"
userBase="DC=<sub_dc>,DC=com"
userSubtree="true"
userSearch="(sAMAccountName={0})"
userRoleName="memberOf"
roleBase="DC=<sub_dc>,DC=com"
roleSubtree="true"
roleSearch="(uniqueMember={0})"
roleName="cn"
rolenested="true"
/>
</Realm>
我看到上面security-role-ref中提到的包括LDAP_GROUP在内的用户的所有ldap组都是根据日志找到的。但是,似乎没有使用角色引用。尝试“http://:8080/examples/jsp/security/protected/index.jsp”给出:
org.apache.catalina.authenticator.AuthenticatorBase.invoke Calling authenticate()
org.apache.catalina.authenticator.FormAuthenticator.doAuthenticate Restore request from session 'BB74A040FCCEEEDC150EC5671B6BF7B6'
org.apache.catalina.authenticator.AuthenticatorBase.register Authenticated 'ldap_user' with type 'FORM'
org.apache.catalina.authenticator.AuthenticatorBase.register Session ID changed on authentication from [BB74A040FCCEEEDC150EC5671B6BF7B6] to [A5735CBE706B62943EB9B29899C0CCCD]
org.apache.catalina.authenticator.FormAuthenticator.doAuthenticate Proceed to restored request
org.apache.catalina.authenticator.AuthenticatorBase.invoke Calling accessControl()
org.apache.catalina.realm.RealmBase.hasResourcePermission Checking roles GenericPrincipal[ldap_user(CN=LDAP_GROUP,DC=com,<many_more_ldap_group_DNs>,)]
org.apache.catalina.realm.RealmBase.hasRole Username ldap_user does NOT have role tomcat
org.apache.catalina.realm.RealmBase.hasResourcePermission No role found: tomcat
org.apache.catalina.realm.RealmBase.hasRole Username ldap_user does NOT have role role1
org.apache.catalina.realm.RealmBase.hasResourcePermission No role found: role1
org.apache.catalina.authenticator.AuthenticatorBase.invoke Failed accessControl() test
我尝试在 $TOMCAT_HOME/conf/tomcat-users.xml 中定义和删除 <role rolename="tomcat"/>
以及在 security-role-ref 中定义没有专有名称的 LDAP_GROUP 但这并没有什么区别.
有什么建议吗?提前致谢。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。