From 21b931e22fcbcbce224da7768e63c997a2d84a4d Mon Sep 17 00:00:00 2001 From: guangning Date: Thu, 22 Sep 2022 10:33:43 +0800 Subject: [PATCH 1/4] Update authentication failed metrics --- .../broker/authentication/AuthenticationProviderList.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderList.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderList.java index c7a0387b66784..c07e883b0e5af 100644 --- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderList.java +++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderList.java @@ -28,6 +28,7 @@ import javax.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; import org.apache.pulsar.broker.ServiceConfiguration; +import org.apache.pulsar.broker.authentication.metrics.AuthenticationMetrics; import org.apache.pulsar.common.api.AuthData; /** @@ -58,8 +59,14 @@ static T applyAuthProcessor(List processors, AuthProcessor authF } if (null == authenticationException) { + AuthenticationMetrics.authenticateFailure( + AuthenticationProviderList.class.getSimpleName(), + "authentication-provider-list", "Authentication required"); throw new AuthenticationException("Authentication required"); } else { + AuthenticationMetrics.authenticateFailure( + AuthenticationProviderList.class.getSimpleName(), + "authentication-provider-list", authenticationException.getMessage()); throw authenticationException; } From 39128da0c4392899c571342612b2022b54740cda Mon Sep 17 00:00:00 2001 From: guangning Date: Sat, 24 Sep 2022 09:58:38 +0800 Subject: [PATCH 2/4] Fixed unit test --- .../broker/authentication/AuthenticationProviderList.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderList.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderList.java index c07e883b0e5af..af537528364fe 100644 --- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderList.java +++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderList.java @@ -66,7 +66,9 @@ static T applyAuthProcessor(List processors, AuthProcessor authF } else { AuthenticationMetrics.authenticateFailure( AuthenticationProviderList.class.getSimpleName(), - "authentication-provider-list", authenticationException.getMessage()); + "authentication-provider-list", + authenticationException.getMessage() != null + ? authenticationException.getMessage(): "Authentication required"); throw authenticationException; } From d1e9dc76258e80f9b85840d15cba5fdc09f60da3 Mon Sep 17 00:00:00 2001 From: guangning Date: Sat, 24 Sep 2022 12:17:24 +0800 Subject: [PATCH 3/4] Fixed space --- .../broker/authentication/AuthenticationProviderList.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderList.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderList.java index af537528364fe..a3126fe6761dc 100644 --- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderList.java +++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderList.java @@ -64,11 +64,9 @@ static T applyAuthProcessor(List processors, AuthProcessor authF "authentication-provider-list", "Authentication required"); throw new AuthenticationException("Authentication required"); } else { - AuthenticationMetrics.authenticateFailure( - AuthenticationProviderList.class.getSimpleName(), - "authentication-provider-list", - authenticationException.getMessage() != null - ? authenticationException.getMessage(): "Authentication required"); + AuthenticationMetrics.authenticateFailure(AuthenticationProviderList.class.getSimpleName(), + "authentication-provider-list",authenticationException.getMessage() != null + ? authenticationException.getMessage() : "Authentication required"); throw authenticationException; } From d5b75179459c135a727b9dc8e11a6f6a2a73373f Mon Sep 17 00:00:00 2001 From: guangning Date: Sat, 24 Sep 2022 12:20:38 +0800 Subject: [PATCH 4/4] Fixed space --- .../broker/authentication/AuthenticationProviderList.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderList.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderList.java index a3126fe6761dc..f921a6f1e0918 100644 --- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderList.java +++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderList.java @@ -65,7 +65,8 @@ static T applyAuthProcessor(List processors, AuthProcessor authF throw new AuthenticationException("Authentication required"); } else { AuthenticationMetrics.authenticateFailure(AuthenticationProviderList.class.getSimpleName(), - "authentication-provider-list",authenticationException.getMessage() != null + "authentication-provider-list", + authenticationException.getMessage() != null ? authenticationException.getMessage() : "Authentication required"); throw authenticationException; }