Skip to content

Commit

Permalink
I18N-1308: Add more debug logs to security methods (#228)
Browse files Browse the repository at this point in the history
Add more logging to help pinpoint where the failures are
happening in the security layer
  • Loading branch information
byronantak authored Jan 23, 2025
1 parent d518ccd commit 7c9db9d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public UserDetailImplOAuth2UserService(SecurityConfig securityConfig, UserServic

@Override
public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2AuthenticationException {
logger.debug("OAuth2UserRequest flow initiated");
Assert.notNull(userRequest, "userRequest cannot be null");

if (!StringUtils.hasText(
Expand Down Expand Up @@ -145,6 +146,7 @@ public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2Authentic
Map<String, Object> userAttributes = response.getBody();

// This is the part of the implementation that diverge from {@link DefaultOAuth2UserService}
logger.debug("Successful OAuth2UserRequest flow");
logger.debug("user attributes: {}", userAttributes);
return getOAuth2UserDetailsImpl(userRequest, userNameAttributeName, userAttributes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ public class UserDetailsServiceImpl implements UserDetailsService {

@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
logger.debug("Attempting user database authentication for username: {}", username);
User user = userRepository.findByUsername(username);

if (user == null) {
logger.debug("User not found: {}", username);
throw new UsernameNotFoundException("User [" + username + "] is not found in the database.");
}

logger.debug("Database authentication user found: {}", user.getUsername());
return new UserDetailsImpl(user);
}
}

0 comments on commit 7c9db9d

Please sign in to comment.