Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sahandilshan committed Jul 28, 2023
1 parent 7f9cf0f commit 2c8d0cd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3023,12 +3023,12 @@ private String handlePreConsent(OAuth2Parameters oauth2Params, AuthenticatedUser
ServiceProvider serviceProvider = getServiceProvider(clientId);

Map<String, Object> params = new HashMap<>();
params.put("clientId", clientId);
params.put(LogConstants.InputKeys.CLIENT_ID, clientId);
try {
params.put("user", user.getUserId());
params.put(LogConstants.InputKeys.USER_ID, user.getUserId());
} catch (UserIdNotFoundException e) {
if (StringUtils.isNotBlank(user.getAuthenticatedSubjectIdentifier())) {
params.put("user", LoggerUtils.isLogMaskingEnable ? LoggerUtils.getMaskedContent(
params.put(LogConstants.InputKeys.USER, LoggerUtils.isLogMaskingEnable ? LoggerUtils.getMaskedContent(
user.getAuthenticatedSubjectIdentifier()) : user.getAuthenticatedSubjectIdentifier());
}
}
Expand All @@ -3044,11 +3044,16 @@ private String handlePreConsent(OAuth2Parameters oauth2Params, AuthenticatedUser
+ spTenantDomain + " for user: " + user.toFullQualifiedUsername());
}
if (LoggerUtils.isDiagnosticLogsEnabled()) {
params.put("skipConsent", "true");
LoggerUtils.triggerDiagnosticLogEvent(OAuthConstants.LogConstants.OAUTH_INBOUND_SERVICE, params,
OAuthConstants.LogConstants.SUCCESS,
"'skipConsent' is enabled for the OAuth client. Hence consent claims not generated.",
"generate-consent-claims", null);
params.put("skip consent", "true");
DiagnosticLog.DiagnosticLogBuilder diagnosticLogBuilder = new DiagnosticLog.DiagnosticLogBuilder(
OAuthConstants.LogConstants.OAUTH_INBOUND_SERVICE,
EndpointConstants.LogConstants.ActionIDs.GENERATE_CONSENT_CLAIMS);
diagnosticLogBuilder.inputParams(params)
.resultStatus(DiagnosticLog.ResultStatus.SUCCESS)
.logDetailLevel(DiagnosticLog.LogDetailLevel.APPLICATION)
.resultMessage("'skipConsent' is enabled for the OAuth client. Hence consent claims not " +
"generated.");
LoggerUtils.triggerDiagnosticLogEvent(diagnosticLogBuilder);
}
return StringUtils.EMPTY;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public static class ActionIDs {
public static final String VALIDATE_SCOPES_BEFORE_CONSENT = "validate-scopes-before-consent";
public static final String HAND_OVER_TO_FRAMEWORK = "hand-over-to-framework";
public static final String PERSIST_OAUTH_SCOPE_CONSENT = "persist-oauth-scope-consent";
public static final String GENERATE_CONSENT_CLAIMS = "generate-consent-claims";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ public static class ActionIDs {
public static final String ISSUE_ID_TOKEN = "issue-id-token";
public static final String VALIDATE_AUTHORIZATION_CODE = "validate-authz-code";
public static final String ISSUE_AUTHZ_CODE = "issue-authz-code";

}

/**
Expand All @@ -102,7 +101,6 @@ public static class InputKeys {
public static final String AUTHORIZED_SCOPES = "authorized scopes";
public static final String GRANT_TYPE = "grant type";
public static final String AUTHORIZATION_CODE = "authorization code";

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ private boolean validateAuthzCodeFromRequest(AuthzCodeDO authzCodeBean, String c
if (LoggerUtils.isDiagnosticLogsEnabled()) {
diagnosticLogBuilder.resultMessage("Invalid authorization code received. Couldn't find persisted data" +
" for authorization code.")
.inputParam("authorization code", authzCode)
.inputParam(OAuth2Constants.LogConstants.InputKeys.AUTHORIZATION_CODE, authzCode)
.resultStatus(DiagnosticLog.ResultStatus.FAILED)
.logDetailLevel(DiagnosticLog.LogDetailLevel.APPLICATION);
LoggerUtils.triggerDiagnosticLogEvent(diagnosticLogBuilder);
Expand All @@ -405,7 +405,7 @@ private boolean validateAuthzCodeFromRequest(AuthzCodeDO authzCodeBean, String c
clearTokenCache(authzCodeBean, clientId);
if (LoggerUtils.isDiagnosticLogsEnabled()) {
diagnosticLogBuilder.resultMessage("Inactive authorization code received.")
.inputParam("authorization code", authzCode)
.inputParam(OAuth2Constants.LogConstants.InputKeys.AUTHORIZATION_CODE, authzCode)
.resultStatus(DiagnosticLog.ResultStatus.FAILED);
LoggerUtils.triggerDiagnosticLogEvent(diagnosticLogBuilder);
}
Expand Down

0 comments on commit 2c8d0cd

Please sign in to comment.