diff --git a/claims.go b/claims.go index d50ff3d..a569c59 100644 --- a/claims.go +++ b/claims.go @@ -5,7 +5,7 @@ package jwt // common basis for validation, it is required that an implementation is able to // supply at least the claim names provided in // https://datatracker.ietf.org/doc/html/rfc7519#section-4.1 namely `exp`, -// `iat`, `nbf`, `iss`, `sub` and `aud`. +// `iat`, `nbf`, `iss`, `sub`, `aud` and `jti“. type Claims interface { GetExpirationTime() (*NumericDate, error) GetIssuedAt() (*NumericDate, error) @@ -13,4 +13,5 @@ type Claims interface { GetIssuer() (string, error) GetSubject() (string, error) GetAudience() (ClaimStrings, error) + GetID() (string, error) } diff --git a/map_claims.go b/map_claims.go index b2b51a1..6442fba 100644 --- a/map_claims.go +++ b/map_claims.go @@ -39,6 +39,11 @@ func (m MapClaims) GetSubject() (string, error) { return m.parseString("sub") } +// GetID implements the Claims interface. +func (m MapClaims) GetID() (string, error) { + return m.parseString("jti") +} + // parseNumericDate tries to parse a key in the map claims type as a number // date. This will succeed, if the underlying type is either a [float64] or a // [json.Number]. Otherwise, nil will be returned. diff --git a/registered_claims.go b/registered_claims.go index 77951a5..465d82e 100644 --- a/registered_claims.go +++ b/registered_claims.go @@ -61,3 +61,8 @@ func (c RegisteredClaims) GetIssuer() (string, error) { func (c RegisteredClaims) GetSubject() (string, error) { return c.Subject, nil } + +// GetID implements the Claims interface. +func (c RegisteredClaims) GetID() (string, error) { + return c.ID, nil +}