【发布时间】: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 服务器的良好响应