Skip to content

Commit

Permalink
add login validation to LdapAuthenticationProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
nkonev committed Sep 19, 2024
1 parent 8fdedff commit ea3e7cc
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;

import static name.nkonev.aaa.converter.UserAccountConverter.validateLengthAndTrimLogin;
import static name.nkonev.aaa.utils.TimeUtil.getNowUTC;

// https://spring.io/guides/gs/authenticating-ldap
Expand Down Expand Up @@ -66,7 +67,7 @@ public class LdapAuthenticationProvider implements AuthenticationProvider, Confl
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
if (aaaProperties.ldap().auth().enabled()) {
UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken = (UsernamePasswordAuthenticationToken) authentication;
var userName = usernamePasswordAuthenticationToken.getPrincipal().toString();
var userName = validateLengthAndTrimLogin(usernamePasswordAuthenticationToken.getPrincipal().toString(), false);
var password = usernamePasswordAuthenticationToken.getCredentials().toString();

var encodedPassword = encodePassword(password);
Expand Down

0 comments on commit ea3e7cc

Please sign in to comment.