Skip to content

Commit

Permalink
Exclude username in password grant error message using OAuth config
Browse files Browse the repository at this point in the history
  • Loading branch information
BiyonFernando committed Dec 5, 2024
1 parent 654bc26 commit 7f869f2
Showing 1 changed file with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,16 +388,8 @@ private AuthenticatedUser validateUserCredentials(OAuth2AccessTokenReqDTO tokenR
if (isPublishPasswordGrantLoginEnabled) {
publishAuthenticationData(tokenReq, false, serviceProvider);
}
if (MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equalsIgnoreCase(MultitenantUtils.getTenantDomain
(tokenReq.getResourceOwnerUsername()))) {
throw new IdentityOAuth2Exception("Authentication failed for " + tenantAwareUserName);
}
username = tokenReq.getResourceOwnerUsername();
if (IdentityTenantUtil.isTenantQualifiedUrlsEnabled()) {
// For tenant qualified urls, no need to send fully qualified username in response.
username = tenantAwareUserName;
}
throw new IdentityOAuth2Exception("Authentication failed for " + username);

throw new IdentityOAuth2Exception("Authentication failed");
} catch (UserStoreClientException e) {
if (isPublishPasswordGrantLoginEnabled) {
publishAuthenticationData(tokenReq, false, serviceProvider);
Expand Down Expand Up @@ -435,7 +427,7 @@ private AuthenticatedUser validateUserCredentials(OAuth2AccessTokenReqDTO tokenR
if (log.isDebugEnabled()) {
log.debug(message, e);
}
throw new IdentityOAuth2Exception(message);
throw new IdentityOAuth2Exception("Authentication failed");
} finally {
UserCoreUtil.removeUserMgtContextInThreadLocal();
if (log.isDebugEnabled()) {
Expand Down

0 comments on commit 7f869f2

Please sign in to comment.