Announcement

Collapse
No announcement yet.

JNDIRealm and LDAP

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • JNDIRealm and LDAP

    Hallo,

    Ich versuche eine Web-Applikation im Tomcat via LDAP zu schützen. ZUvor hat die Applikation (Applet) dies selbst erledigt. Da nun mehrere teilweise sensible Daten hinzugekommen sind, möchte ich die ganze Web-App schützen.Ich habe daher einen JNDI-Realm dem Context hinzugefügt:
    <Realm className="org.apache.catalina.realm.JNDIRealm" debug="99"
    connectionURL="ldap://gssun001:389"
    userBase="ou=LDAPusers,dc=prodv"
    userSearch="(cn={0})"
    roleBase="ou=LDAPusers,dc=prodv"
    roleName="(cn={0})"
    roleSearch="(userPassword={0})"
    />

    Weiterhin habe ich natürlich den Deployment.Deskriptor (web.xml) angepasst:

    <!-- Define the Login Configuration for this Application -->
    <login-config>
    <auth-method>FORM</auth-method>
    <realm-name>theApplication</realm-name>
    <form-login-config>
    <form-login-page>/login.html</form-login-page>
    <form-error-page>/autherr.html</form-error-page>
    </form-login-config>
    </login-config>

    <!-- Security roles referenced by this web application -->
    <security-role>
    <description>
    The role that is required to log in to the Manager Application
    </description>
    <role-name>manager</role-name>
    </security-role>

    Wenn ich auf die Web-App zugreifen möchte, so erscheint zunächst die login.html. So weit, so gut. Wenn ich in der Form Username und Passwort korrekt eingebe, so sehe ich im Log:

    Searching for gast
    base: ou=LDAPusers,dc=prodv filter: (cn=gast)
    entry found for gast with dn cn=gast,ou=LDAPusers,dc=prodv
    validating credentials by binding as the user
    binding as cn=gast,ou=LDAPusers,dc=prodv
    Username gast successfully authenticated
    getRoles(cn=gast,ou=LDAPusers,dc=prodv)
    Searching role base 'ou=LDAPusers,dc=prodv' for attribute '(cn={0})'
    With filter expression '(userPassword=cn=gast,ou=LDAPusers,dc=prodv)'
    Returning 0 roles
    Username gast does NOT have role manager

    Danach antwortet Tomcat mit einem "403: Access to the requested resource has been denied"

    Anscheinend akzeptiert Tomcat die übergebenen credentials, kann dies aber nicht richtig auswerten. Wenn ich dagegen ein falsches Passwort eingebe, erscheint im Log:

    Searching for gast
    base: ou=LDAPusers,dc=prodv filter: (cn=gast)
    entry found for gast with dn cn=gast,ou=LDAPusers,dc=prodv
    validating credentials by binding as the user
    binding as cn=gast,ou=LDAPusers,dc=prodv
    bind attempt failed
    Username gast NOT successfully authenticated

    Ich sehe im LDAP aber keinerlei Attribute, die etwas mit Rollen zu tun haben. Einzig was ich habe sind userName und userPassword.

    Igendwie muss das doch funktionieren, oder?
Working...
X