You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/01/27 07:59:56 UTC

[GitHub] [pulsar] RobertIndie commented on a change in pull request #9321: [pulsar-broker]Add alerts for expired/expiring soon tokens

RobertIndie commented on a change in pull request #9321:
URL: https://github.com/apache/pulsar/pull/9321#discussion_r565094843



##########
File path: pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderToken.java
##########
@@ -202,6 +211,10 @@ private static String validateToken(final String token) throws AuthenticationExc
 
             return jwt;
         } catch (JwtException e) {
+            if (e instanceof ExpiredJwtException) {
+                String expiredTime = new Date(1000L * (Integer) ((ExpiredJwtException) e).getClaims().get("exp")).toString();
+                expiredTokenMetrics.labels(expiredTime).inc();

Review comment:
       Thanks. It seems unnecessary to record expired time here. Here I made some changes: Remove the `expiredTime` label in `expiredTokenMetrics`, use `Histogram` to record tokens that are about to expire and the corresponding remaining time.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org