fix(deps): update module github.com/lestrrat-go/jwx/v2 to v3

This commit is contained in:
Renovate
2025-12-29 17:15:10 +01:00
committed by Joakim Olsson
parent c951b8b2a6
commit 058c818246
3 changed files with 54 additions and 45 deletions
+21 -21
View File
@@ -8,10 +8,10 @@ import (
"time"
"github.com/google/uuid"
"github.com/lestrrat-go/jwx/v2/jwa"
"github.com/lestrrat-go/jwx/v2/jwk"
"github.com/lestrrat-go/jwx/v2/jws"
"github.com/lestrrat-go/jwx/v2/jwt"
"github.com/lestrrat-go/jwx/v3/jwa"
"github.com/lestrrat-go/jwx/v3/jwk"
"github.com/lestrrat-go/jwx/v3/jws"
"github.com/lestrrat-go/jwx/v3/jwt"
)
const (
@@ -21,12 +21,12 @@ const (
// JWTService handles JWT signing and JWKS generation
type JWTService struct {
privateKey *rsa.PrivateKey
jwkSet jwk.Set
issuer string
audience string
adminClaim string
emailClaim string
privateKey *rsa.PrivateKey
jwkSet jwk.Set
issuer string
audience string
adminClaim string
emailClaim string
}
// NewJWTService creates a new JWT service with a generated RSA key pair
@@ -38,7 +38,7 @@ func NewJWTService(issuer, audience, adminClaim, emailClaim string) (*JWTService
}
// Create JWK from private key
key, err := jwk.FromRaw(privateKey)
key, err := jwk.Import(privateKey)
if err != nil {
return nil, fmt.Errorf("create JWK from private key: %w", err)
}
@@ -48,7 +48,7 @@ func NewJWTService(issuer, audience, adminClaim, emailClaim string) (*JWTService
if err := key.Set(jwk.KeyIDKey, keyID); err != nil {
return nil, fmt.Errorf("set key ID: %w", err)
}
if err := key.Set(jwk.AlgorithmKey, jwa.RS256); err != nil {
if err := key.Set(jwk.AlgorithmKey, jwa.RS256()); err != nil {
return nil, fmt.Errorf("set algorithm: %w", err)
}
if err := key.Set(jwk.KeyUsageKey, "sig"); err != nil {
@@ -68,12 +68,12 @@ func NewJWTService(issuer, audience, adminClaim, emailClaim string) (*JWTService
}
return &JWTService{
privateKey: privateKey,
jwkSet: jwkSet,
issuer: issuer,
audience: audience,
adminClaim: adminClaim,
emailClaim: emailClaim,
privateKey: privateKey,
jwkSet: jwkSet,
issuer: issuer,
audience: audience,
adminClaim: adminClaim,
emailClaim: emailClaim,
}, nil
}
@@ -98,20 +98,20 @@ func (s *JWTService) SignToken(claims map[string]interface{}) (string, error) {
}
// Create JWK from private key for signing
key, err := jwk.FromRaw(s.privateKey)
key, err := jwk.Import(s.privateKey)
if err != nil {
return "", fmt.Errorf("create signing key: %w", err)
}
// Get key ID from JWKS
pubKey, _ := s.jwkSet.Key(0)
keyID := pubKey.KeyID()
keyID, _ := pubKey.KeyID()
if err := key.Set(jwk.KeyIDKey, keyID); err != nil {
return "", fmt.Errorf("set key ID: %w", err)
}
// Sign the token
signed, err := jwt.Sign(token, jwt.WithKey(jwa.RS256, key))
signed, err := jwt.Sign(token, jwt.WithKey(jwa.RS256(), key))
if err != nil {
return "", fmt.Errorf("sign token: %w", err)
}