Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: jwt v5 (#9961)

Danny Xuedf6d8f5172b
diff --git a/backend/api/auth/auth.go b/backend/api/auth/auth.go
index ae5ba86e1b..342ca2b868 100644
--- a/backend/api/auth/auth.go
+++ b/backend/api/auth/auth.go
@@ -15,7 +15,7 @@ import (
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
- "github.com/golang-jwt/jwt/v4"
+ "github.com/golang-jwt/jwt/v5"
errs "github.com/pkg/errors"
"github.com/bytebase/bytebase/backend/common"
@@ -148,8 +148,7 @@ func (in *APIAuthInterceptor) authenticate(ctx context.Context, accessTokenStr s
}
return nil, status.Errorf(codes.Unauthenticated, "unexpected access token kid=%v", t.Header["kid"])
}); err != nil {
- var ve *jwt.ValidationError
- if errors.As(err, &ve) && ve.Errors == jwt.ValidationErrorExpired {
+ if errors.Is(err, jwt.ErrTokenExpired) {
return 0, status.Errorf(codes.Unauthenticated, "access token expired")
}
return 0, status.Errorf(codes.Unauthenticated, "failed to parse claim")
diff --git a/go.mod b/go.mod
index 3b726d46bf..1d8abfc54b 100644
--- a/go.mod
+++ b/go.mod
@@ -26,6 +26,7 @@ require (
github.com/go-sql-driver/mysql v1.7.1
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/golang-jwt/jwt/v4 v4.5.0
+ github.com/golang-jwt/jwt/v5 v5.2.0
github.com/google/cel-go v0.18.2
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.5.0
@@ -111,7 +112,6 @@ require (
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
- github.com/golang-jwt/jwt/v5 v5.2.0 // indirect
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
github.com/golang-sql/sqlexp v0.1.0 // indirect
github.com/golang/glog v1.2.0 // indirect