diff --git a/src/main/java/io/cdap/plugin/gcp/common/GCPUtils.java b/src/main/java/io/cdap/plugin/gcp/common/GCPUtils.java index 4ebae9bb00..c28ff5af04 100644 --- a/src/main/java/io/cdap/plugin/gcp/common/GCPUtils.java +++ b/src/main/java/io/cdap/plugin/gcp/common/GCPUtils.java @@ -118,7 +118,14 @@ public static GoogleCredentials loadServiceAccountCredentials(String serviceAcco boolean isServiceAccountFilePath) throws IOException { try (InputStream inputStream = openServiceAccount(serviceAccount, isServiceAccountFilePath)) { - return GoogleCredentials.fromStream(inputStream); + GoogleCredentials credentials = GoogleCredentials.fromStream(inputStream); + if (!(credentials instanceof ServiceAccountCredentials)) { + // Audit log: record usage of credential types other than 'service_account' supplied via the + // service account file path / JSON, so that such usage can be identified. + LOG.warn("Audit: loaded GCP credentials of type '{}' from the service account {}.", + credentials.getClass().getSimpleName(), isServiceAccountFilePath ? "file path" : "JSON"); + } + return credentials; } }