spring-securityspring-security-ldap

Is it possible to authenticate with bind on ldap using the "username" in a webflux application with spring security like in php?


I have searched on google but I always find only methods using the dn but for the login I don't have the dn and the username is not part of the dn. I also have looked into the code and the various different errors I have encountered and I have found nothing so far.

2020-03-11 12:21:26.718 TRACE 26996 --- [ctor-http-nio-2] o.s.w.s.adapter.HttpWebHandlerAdapter    : [0b7f4a17] Completed 302 FOUND, headers={masked}
2020-03-11 12:21:26.719 TRACE 26996 --- [ctor-http-nio-2] o.s.h.s.r.ReactorHttpHandlerAdapter      : [0b7f4a17] Handling completed
2020-03-11 12:21:26.730 TRACE 26996 --- [ctor-http-nio-2] o.s.w.s.adapter.HttpWebHandlerAdapter    : [0b7f4a17] HTTP GET "/login", headers={masked}
2020-03-11 12:21:26.734 TRACE 26996 --- [ctor-http-nio-2] o.s.w.s.adapter.HttpWebHandlerAdapter    : [0b7f4a17] Completed 200 OK, headers={masked}
2020-03-11 12:21:26.734 TRACE 26996 --- [ctor-http-nio-2] o.s.h.s.r.ReactorHttpHandlerAdapter      : [0b7f4a17] Handling completed
2020-03-11 12:21:27.331 TRACE 26996 --- [ctor-http-nio-2] o.s.w.s.adapter.HttpWebHandlerAdapter    : [0b7f4a17] HTTP GET "/favicon.ico", headers={masked}
2020-03-11 12:21:27.336 TRACE 26996 --- [ctor-http-nio-2] o.s.w.s.adapter.HttpWebHandlerAdapter    : [0b7f4a17] Completed 302 FOUND, headers={masked}
2020-03-11 12:21:27.337 TRACE 26996 --- [ctor-http-nio-2] o.s.h.s.r.ReactorHttpHandlerAdapter      : [0b7f4a17] Handling completed
2020-03-11 12:21:27.341 TRACE 26996 --- [ctor-http-nio-2] o.s.w.s.adapter.HttpWebHandlerAdapter    : [0b7f4a17] HTTP GET "/login", headers={masked}
2020-03-11 12:21:27.345 TRACE 26996 --- [ctor-http-nio-2] o.s.w.s.adapter.HttpWebHandlerAdapter    : [0b7f4a17] Completed 200 OK, headers={masked}
2020-03-11 12:21:27.345 TRACE 26996 --- [ctor-http-nio-2] o.s.h.s.r.ReactorHttpHandlerAdapter      : [0b7f4a17] Handling completed
2020-03-11 12:22:33.067 TRACE 26996 --- [ctor-http-nio-2] o.s.w.s.adapter.HttpWebHandlerAdapter    : [0b7f4a17] HTTP POST "/login", headers={masked}
2020-03-11 12:22:33.092 TRACE 26996 --- [ctor-http-nio-2] o.s.http.codec.FormHttpMessageReader     : [0b7f4a17] Read form fields [username, password, _csrf] (content masked)
2020-03-11 12:22:33.103 DEBUG 26996 --- [oundedElastic-1] o.s.s.authentication.ProviderManager     : Authentication attempt using org.springframework.security.ldap.authentication.LdapAuthenticationProvider
2020-03-11 12:22:33.106 DEBUG 26996 --- [oundedElastic-1] o.s.s.l.a.LdapAuthenticationProvider     : Processing authentication request for user: <username that worked in php>
2020-03-11 12:22:33.131 TRACE 26996 --- [oundedElastic-1] o.s.w.s.adapter.HttpWebHandlerAdapter    : [0b7f4a17] Completed 302 FOUND, headers={masked}
2020-03-11 12:22:33.132 TRACE 26996 --- [oundedElastic-1] o.s.h.s.r.ReactorHttpHandlerAdapter      : [0b7f4a17] Handling completed
2020-03-11 12:22:33.142 TRACE 26996 --- [ctor-http-nio-2] o.s.w.s.adapter.HttpWebHandlerAdapter    : [0b7f4a17] HTTP GET "/login?error", headers={masked}
2020-03-11 12:22:33.146 TRACE 26996 --- [ctor-http-nio-2] o.s.w.s.adapter.HttpWebHandlerAdapter    : [0b7f4a17] Completed 200 OK, headers={masked}
2020-03-11 12:22:33.146 TRACE 26996 --- [ctor-http-nio-2] o.s.h.s.r.ReactorHttpHandlerAdapter      : [0b7f4a17] Handling completed

that's the log output with trace enabled when I try to login.


Solution

  • I found out how! I needed to use ActiveDirectoryLdapAuthenticationProvider instead of LdapAuthenticationProvider with BindAuthenticator.