jetty ldap身份验证

tuwxkamq  于 2021-07-09  发布在  Java
关注(0)|答案(1)|浏览(397)

我正在尝试使用ldap(active directory)身份验证设置Jetty9.1。我疯狂地在谷歌上搜索,却找不到我需要的答案。。。我扩展了包含的演示应用程序以使用ldap。当访问该页面时,我得到以下消息:problem accessing/test jaas/auth.html。理由:!角色。在控制台/日志中,我看到“found user::true”,因此找到了用户,但导致问题的是角色匹配。
希望有人能给我一些建议。。。
以下是我的配置:
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>

登录.conf:

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>
fnx2tebb

fnx2tebb1#

我想我找到了答案,把它放在这里,这样别人可能会用到它。
我正试图通过你的身份验证。我在web.xml auth约束和安全角色中设置了正确的名称,但运气不好。当我将rolebasedn更改为一个真正的组并将其添加到web.xml时,它就开始工作了。在许多例子中,我发现他们在rolebasedn中使用了ou,不知道是因为我们的广告中的一些配置还是什么,但对我来说不起作用。。。
所以:
rolebasedn=“cn=集团,ou=,…”
将组添加到web.xml就是答案。:)

相关问题