Skip to content

Commit

Permalink
Merge pull request #5697 from sadilchamishka/allow-diagnostic-log-pub…
Browse files Browse the repository at this point in the history
…lish-for-myaccount

Allow diagnostic log publishing for myaccount
  • Loading branch information
sadilchamishka authored May 14, 2024
2 parents 369c114 + e0fec6e commit 6a11235
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ public static class ApplicationManagement {
public static final String REGENERATE_CLIENT_SECRET_ACTION = "regenerate-client-secret";
public static final String UPDATE_APP_STATE_ACTION = "update-app-state";
public static final String CONSOLE_CLIENT_ID = "CONSOLE";
public static final String MY_ACCOUNT_CLIENT_ID = "MY_ACCOUNT";
public static final String CONSOLE_APP_NAME = "Console";
public static final String MY_ACCOUNT_APP_NAME = "My Account";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@

import static org.wso2.carbon.identity.central.log.mgt.utils.LogConstants.ApplicationManagement.CONSOLE_APP_NAME;
import static org.wso2.carbon.identity.central.log.mgt.utils.LogConstants.ApplicationManagement.CONSOLE_CLIENT_ID;
import static org.wso2.carbon.identity.central.log.mgt.utils.LogConstants.ApplicationManagement.MY_ACCOUNT_APP_NAME;
import static org.wso2.carbon.identity.central.log.mgt.utils.LogConstants.ApplicationManagement.MY_ACCOUNT_CLIENT_ID;
import static org.wso2.carbon.identity.central.log.mgt.utils.LogConstants.ENABLE_LOG_MASKING;
import static org.wso2.carbon.identity.central.log.mgt.utils.LogConstants.LOGGABLE_USER_CLAIMS;
import static org.wso2.carbon.identity.event.IdentityEventConstants.Event.PUBLISH_AUDIT_LOG;
Expand Down Expand Up @@ -173,9 +171,9 @@ public static void triggerDiagnosticLogEvent(DiagnosticLog.DiagnosticLogBuilder
try {
Map<String, Object> diagnosticLogProperties = new HashMap<>();
DiagnosticLog diagnosticLog = diagnosticLogBuilder.build();
/* As the Console and MyAccount application are managed by the identity server, the diagnostic logs are not
/* As the Console application is used to access the identity server resources, the diagnostic logs are not
required to be emitted. */
if (isConsoleOrMyAccountApp(diagnosticLog)) {
if (isConsoleApp(diagnosticLog)) {
return;
}
IdentityEventService eventMgtService =
Expand Down Expand Up @@ -392,7 +390,7 @@ public static List<String> getLoggableClaimURIs() {
return new ArrayList<>();
}

private static boolean isConsoleOrMyAccountApp(DiagnosticLog diagnosticLog) {
private static boolean isConsoleApp(DiagnosticLog diagnosticLog) {

if (diagnosticLog.getInput() == null) {
return false;
Expand All @@ -401,24 +399,24 @@ private static boolean isConsoleOrMyAccountApp(DiagnosticLog diagnosticLog) {
List<?> clientIDs;
Object clientIDInputObj = diagnosticLog.getInput().get(LogConstants.InputKeys.CLIENT_ID);
if (clientIDInputObj instanceof String) {
return CONSOLE_CLIENT_ID.equals(clientIDInputObj) || MY_ACCOUNT_CLIENT_ID.equals(clientIDInputObj);
return CONSOLE_CLIENT_ID.equals(clientIDInputObj);
}
Object clientNameInputObj = diagnosticLog.getInput().get(LogConstants.InputKeys.APPLICATION_NAME);
if (clientNameInputObj instanceof String) {
return CONSOLE_APP_NAME.equals(clientNameInputObj) || MY_ACCOUNT_APP_NAME.equals(clientNameInputObj);
return CONSOLE_APP_NAME.equals(clientNameInputObj);
}
if (clientIDInputObj instanceof List<?>) {
clientIDs = (List<?>) diagnosticLog.getInput().get(LogConstants.InputKeys.CLIENT_ID);
if (CollectionUtils.isNotEmpty(clientIDs)) {
clientID = (String) clientIDs.get(0);
return CONSOLE_CLIENT_ID.equals(clientID) || MY_ACCOUNT_CLIENT_ID.equals(clientID);
return CONSOLE_CLIENT_ID.equals(clientID);
}
}
if (diagnosticLog.getInput().get("client_id") instanceof List<?>) {
clientIDs = (List<?>) diagnosticLog.getInput().get("client_id");
if (CollectionUtils.isNotEmpty(clientIDs)) {
clientID = (String) clientIDs.get(0);
return CONSOLE_CLIENT_ID.equals(clientID) || MY_ACCOUNT_CLIENT_ID.equals(clientID);
return CONSOLE_CLIENT_ID.equals(clientID);
}
}
return false;
Expand Down

0 comments on commit 6a11235

Please sign in to comment.