Skip to content

Commit

Permalink
Merge pull request #12613 from PasanT9/api-key-fix
Browse files Browse the repository at this point in the history
Hide apiKeyValue from endpoint_security
  • Loading branch information
PasanT9 authored Oct 1, 2024
2 parents 2c84b31 + 6ade7ef commit f15a0f4
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,15 @@ public static APIDTO fromAPItoDTO(API model, boolean preserveCredentials,
}
}

if (APIConstants.ENDPOINT_SECURITY_TYPE_API_KEY.equals(productionEndpointType)) {
String apiKeyValue = (String) productionEndpointSecurity
.get(APIConstants.ENDPOINT_SECURITY_API_KEY_VALUE);
if (StringUtils.isNotEmpty(apiKeyValue)) {
productionEndpointSecurity.put(APIConstants.ENDPOINT_SECURITY_API_KEY_VALUE,
new String(cryptoUtil.base64DecodeAndDecrypt(apiKeyValue)));
}
}

endpointSecurity.put(APIConstants.OAuthConstants.ENDPOINT_SECURITY_PRODUCTION,
productionEndpointSecurity);
endpointConfigJson.put(APIConstants.ENDPOINT_SECURITY, endpointSecurity);
Expand Down Expand Up @@ -1184,6 +1193,15 @@ public static APIDTO fromAPItoDTO(API model, boolean preserveCredentials,
}
}

if (APIConstants.ENDPOINT_SECURITY_TYPE_API_KEY.equals(sandboxEndpointType)) {
String apiKeyValue = (String) sandboxEndpointSecurity
.get(APIConstants.ENDPOINT_SECURITY_API_KEY_VALUE);
if (StringUtils.isNotEmpty(apiKeyValue)) {
sandboxEndpointSecurity.put(APIConstants.ENDPOINT_SECURITY_API_KEY_VALUE,
new String(cryptoUtil.base64DecodeAndDecrypt(apiKeyValue)));
}
}

endpointSecurity.put(APIConstants.OAuthConstants.ENDPOINT_SECURITY_SANDBOX,
sandboxEndpointSecurity);
endpointConfigJson.put(APIConstants.ENDPOINT_SECURITY, endpointSecurity);
Expand Down Expand Up @@ -3266,6 +3284,9 @@ private static JSONObject handleEndpointSecurity(API api, JSONObject endpointSec
if (sandboxEndpointSecurity.get(APIConstants.ENDPOINT_SECURITY_PASSWORD) != null) {
sandboxEndpointSecurity.put(APIConstants.ENDPOINT_SECURITY_PASSWORD, "");
}
if (sandboxEndpointSecurity.get(APIConstants.ENDPOINT_SECURITY_API_KEY_VALUE) != null) {
sandboxEndpointSecurity.put(APIConstants.ENDPOINT_SECURITY_API_KEY_VALUE, "");
}
}
if (endpointSecurityElement.get(APIConstants.ENDPOINT_SECURITY_PRODUCTION) != null) {
JSONObject productionEndpointSecurity =
Expand All @@ -3277,6 +3298,9 @@ private static JSONObject handleEndpointSecurity(API api, JSONObject endpointSec
if (productionEndpointSecurity.get(APIConstants.ENDPOINT_SECURITY_PASSWORD) != null) {
productionEndpointSecurity.put(APIConstants.ENDPOINT_SECURITY_PASSWORD, "");
}
if (productionEndpointSecurity.get(APIConstants.ENDPOINT_SECURITY_API_KEY_VALUE) != null) {
productionEndpointSecurity.put(APIConstants.ENDPOINT_SECURITY_API_KEY_VALUE, "");
}
}
return endpointSecurityElement;
}
Expand Down

0 comments on commit f15a0f4

Please sign in to comment.