Skip to content

Commit

Permalink
feature: help find LDAP slowness
Browse files Browse the repository at this point in the history
* Adding debug logs to help figure out why our user sees that LDAP
  authentication takes over 2 minutes.
* This was forked of off the uaa-release 74.5.x branch.

[#186468321](https://www.pivotaltracker.com/story/show/186468321)
  • Loading branch information
bruce-ricard committed Nov 16, 2023
1 parent b413de0 commit e040f55
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,11 @@ public UaaUserDatabase getUserDatabase() {
@Override
public Authentication authenticate(Authentication request) throws AuthenticationException {
logger.debug("Starting external authentication for:"+request);
logger.debug("TKGI-6915 100");
ExternalAuthenticationDetails authenticationData = getExternalAuthenticationDetails(request);
logger.debug("TKGI-6915 200");
UaaUser userFromRequest = getUser(request, authenticationData);
logger.debug("TKGI-6915 300");
if (userFromRequest == null) {
return null;
}
Expand All @@ -126,9 +129,11 @@ public Authentication authenticate(Authentication request) throws Authentication
try {
logger.debug(String.format("Searching for user by (username:%s , origin:%s)", userFromRequest.getUsername(), getOrigin()));
userFromDb = userDatabase.retrieveUserByName(userFromRequest.getUsername(), getOrigin());
logger.debug("TKGI-6915 400");
} catch (UsernameNotFoundException e) {
logger.debug(String.format("Searching for user by (email:%s , origin:%s)", userFromRequest.getEmail(), getOrigin()));
userFromDb = userDatabase.retrieveUserByEmail(userFromRequest.getEmail(), getOrigin());
logger.debug("TKGI-6915 500");
}

// Register new users automatically
Expand All @@ -144,9 +149,13 @@ public Authentication authenticate(Authentication request) throws Authentication
}
}

logger.debug("TKGI-6915 600");

//user is authenticated and exists in UAA
UaaUser user = userAuthenticated(request, userFromRequest, userFromDb);

logger.debug("TKGI-6915 700");

UaaAuthenticationDetails uaaAuthenticationDetails;
if (request.getDetails() instanceof UaaAuthenticationDetails) {
uaaAuthenticationDetails = (UaaAuthenticationDetails) request.getDetails();
Expand All @@ -155,7 +164,9 @@ public Authentication authenticate(Authentication request) throws Authentication
}
UaaAuthentication success = new UaaAuthentication(new UaaPrincipal(user), user.getAuthorities(), uaaAuthenticationDetails);
populateAuthenticationAttributes(success, request, authenticationData);
logger.debug("TKGI-6915 800");
publish(new IdentityProviderAuthenticationSuccessEvent(user, success, user.getOrigin(), IdentityZoneHolder.getCurrentZoneId()));
logger.debug("TKGI-6915 900");
return success;
}

Expand Down

0 comments on commit e040f55

Please sign in to comment.