gpt4 book ai didi

java - jetty ldap 身份验证

转载 作者:搜寻专家 更新时间:2023-11-01 03:38:24 27 4
gpt4 key购买 nike

我正在尝试使用 ldap( Activity 目录)身份验证设置 Jetty 9.1。我疯狂地用谷歌搜索却没有找到我需要的答案......我扩展了包含的演示应用程序以使用 ldap。访问该页面时,我收到以下消息:访问/test-jaas/auth.html 时出现问题。原因: !role 。在控制台/日志中,我看到“找到用户?:真”,所以找到了用户,但导致问题的是角色匹配。

希望有人能给我指点...

这是我的配置:

test-jaas.xml:

<Set name="securityHandler">
<New class="org.eclipse.jetty.security.ConstraintSecurityHandler">
<Set name="loginService">
<New class="org.eclipse.jetty.jaas.JAASLoginService">
<Set name="name">Test JAAS Realm</Set>
<Set name="loginModuleName">xyz</Set>
</New>
</Set>
</New>
</Set>

登录配置文件:

xyz {
org.eclipse.jetty.jaas.spi.LdapLoginModule required
debug="true"
contextFactory="com.sun.jndi.ldap.LdapCtxFactory"
hostname="host.domain"
port="389"
bindDn="CN=xxx,OU=xxx,..."
bindPassword="xxxx"
authenticationMethod="simple"
forceBindingLogin="true"
userBaseDn="ou=xxxx,..."
userRdnAttribute="cn"
userIdAttribute="userPrincipalName"
userPasswordAttribute="unicodePwd"
userObjectClass="user"
roleBaseDn="ou=xxxx,..."
roleNameAttribute="cn"
roleMemberAttribute="userPrincipalName"
roleObjectClass="group";
};

web.xml 包含这些:

  <security-constraint>
<web-resource-collection>
<web-resource-name>JAAS Role</web-resource-name>
<url-pattern>/auth.html</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>user</role-name>
<role-name>*</role-name>
<role-name>**</role-name>
</auth-constraint>
</security-constraint>

<login-config>
<auth-method>FORM</auth-method>
<realm-name>Test JAAS Realm</realm-name>
<form-login-config>
<form-login-page>
/login.html
</form-login-page>
<form-error-page>
/authfail.html
</form-error-page>
</form-login-config>
</login-config>

<security-role>
<role-name>user</role-name>
</security-role>
<security-role>
<role-name>*</role-name>
</security-role>
<security-role>
<role-name>**</role-name>
</security-role>

最佳答案

我想我找到了答案,把它放在这里,这样其他人可能会用到它。

我正在尝试针对一个 ou 进行身份验证。我在 web.xml 中设置了正确的名称 auth-constraint 和 security-role 但没有运气。当我将 roleBaseDn 更改为真实组并将其添加到 web.xml 时,它开始工作。在我发现的许多示例中,他们在 roleBaseDn 中使用了一个 ou,不知道是不是因为我们的 AD 中的某些配置或什么但对我不起作用...

所以:

roleBaseDn="cn=group,ou=xxx,..."

并将组添加到 web.xml 就是答案。 :)

关于java - jetty ldap 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22326795/

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