diff --git a/webapp/src/main/java/org/apache/atlas/web/security/AtlasKeycloakAuthenticationProvider.java b/webapp/src/main/java/org/apache/atlas/web/security/AtlasKeycloakAuthenticationProvider.java index acafc5bc19..6414079214 100644 --- a/webapp/src/main/java/org/apache/atlas/web/security/AtlasKeycloakAuthenticationProvider.java +++ b/webapp/src/main/java/org/apache/atlas/web/security/AtlasKeycloakAuthenticationProvider.java @@ -16,8 +16,10 @@ */ package org.apache.atlas.web.security; +import io.micrometer.core.instrument.Counter; import org.apache.atlas.ApplicationProperties; import org.apache.atlas.keycloak.client.AtlasKeycloakClient; +import org.apache.atlas.service.metrics.MetricUtils; import org.apache.commons.configuration.Configuration; import org.keycloak.adapters.springsecurity.authentication.KeycloakAuthenticationProvider; import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken; @@ -75,8 +77,10 @@ public Authentication authenticate(Authentication authentication) { authentication = new KeycloakAuthenticationToken(token.getAccount(), token.isInteractive(), grantedAuthorities); } } - if(authentication.getName().startsWith("service-account")) { + if(authentication.getName().startsWith("service-account-apikey")) { LOG.info("Validating request for clientId: {}", authentication.getName().substring("service-account-".length())); + + Counter.builder("service_account_apikey_request_counter").register(MetricUtils.getMeterRegistry()).increment(); try{ KeycloakAuthenticationToken keycloakToken = (KeycloakAuthenticationToken)authentication; String bearerToken = keycloakToken.getAccount().getKeycloakSecurityContext().getTokenString();