From 85355341c2d176861b98e6936507288a312091c0 Mon Sep 17 00:00:00 2001 From: Antoine Jouve Date: Tue, 9 Jan 2024 14:10:40 +0100 Subject: [PATCH] fix: add missing time import Signed-off-by: Antoine Jouve --- src/pkg/token/claims/robot/robot.go | 1 + src/pkg/token/claims/v2/claims.go | 2 +- src/server/middleware/security/v2_token.go | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pkg/token/claims/robot/robot.go b/src/pkg/token/claims/robot/robot.go index 9cd9160fe49..7fbd9c31252 100644 --- a/src/pkg/token/claims/robot/robot.go +++ b/src/pkg/token/claims/robot/robot.go @@ -16,6 +16,7 @@ package robot import ( "errors" + "time" "github.com/golang-jwt/jwt/v5" diff --git a/src/pkg/token/claims/v2/claims.go b/src/pkg/token/claims/v2/claims.go index 0af2ef30f04..f46815cd5cf 100644 --- a/src/pkg/token/claims/v2/claims.go +++ b/src/pkg/token/claims/v2/claims.go @@ -40,7 +40,7 @@ type Claims struct { // Valid checks if the issuer is harbor func (c *Claims) Valid() error { - var v = jwt.NewValidator(jwt.WithLeeway(10*time.Second)) + var v = jwt.NewValidator(jwt.WithLeeway(10 * time.Second)) if err := v.Validate(c.RegisteredClaims); err != nil { return err diff --git a/src/server/middleware/security/v2_token.go b/src/server/middleware/security/v2_token.go index 91eb10fe71d..63eeb49f2c2 100644 --- a/src/server/middleware/security/v2_token.go +++ b/src/server/middleware/security/v2_token.go @@ -67,7 +67,7 @@ func (vt *v2Token) Generate(req *http.Request) security.Context { logger.Warningf("failed to decode bearer token: %v", err) return nil } - var v = jwt.NewValidator(jwt.WithLeeway(10*time.Second)) + var v = jwt.NewValidator(jwt.WithLeeway(10 * time.Second)) if err := v.Validate(t.Claims); err != nil { logger.Warningf("failed to decode bearer token: %v", err) return nil