spring-guides / gs-authenticating-ldap

Authenticating a User with LDAP :: Learn how to secure an application with LDAP.
https://spring.io/guides/gs/authenticating-ldap/
Apache License 2.0
97 stars 154 forks source link

spring 3.1 generates deprecated code #51

Closed FerretDave closed 8 months ago

FerretDave commented 8 months ago

Guide: https://spring.io/guides/gs/authenticating-ldap/

indicates that: src/main/java/com/example/authenticatingldap/WebSecurityConfig.java contains: public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { http .authorizeRequests() .anyRequest().fullyAuthenticated() .and() .formLogin();

Unfortunately both authorizeRequests and formLogin are flagged as deprecated in Spring 3.1 The method authorizeRequests() from the type HttpSecurity is deprecated

What is the correct code to use? Can the guide be updated please

Buzzardo commented 8 months ago

Fixed by https://github.com/spring-guides/gs-authenticating-ldap/commit/0ef27b35f87091d458a553c40c425b759db963b2

FerretDave commented 8 months ago

Thank you. This is probably the wrong place to ask (sorry!) however google and docs are not helping me, with this version of the code, how do I tell LDAP to 'bind' for it's initial connection? My corporate server is rejecting the connection (works fine with the local ldif ldap): Caused by: javax.naming.NamingException: [LDAP: error code 1 - 000004DC: LdapErr: DSID-0C090CF4, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v4563

Buzzardo commented 8 months ago

I would ask that question on Stack Overflow. Still, we may be able to get an answer if we loop in an expert. Paging @jzheaux.

FerretDave commented 8 months ago

Thank you, I'd already searched Stack Overflow and found many related to older Spring, and one that covers the exact issue I have:

https://stackoverflow.com/questions/69192599/spring-security-ldap-bind-must-be-completed-on-the-connection

However the answer given hasnt been accepted and doesnt seem to help anyway. If an expert here can confirm the right method for this latest version (and add to the guide?) it'd be ideal. And to clarify - I need to bind using the users provided creds rather than a distinct manager id