From 8e62bbeab5fddfb8e61ec1e1033b37cfcfec8b93 Mon Sep 17 00:00:00 2001 From: "Gerasimos (Makis) Maropoulos" Date: Sun, 26 Nov 2023 22:23:08 +0200 Subject: [PATCH] make Audience a SignOption --- claims.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/claims.go b/claims.go index 74e68ca..00f3965 100644 --- a/claims.go +++ b/claims.go @@ -127,6 +127,16 @@ func (aud *Audience) UnmarshalJSON(data []byte) (err error) { return } +// ApplyClaims implements the `SignOption` interface. +// It sets the Audience field to standard Claims instance. +// +// Usage: +// +// jwt.Sign(jwt.HS256, []byte("secret"), User{Username: "kataras"}, jwt.MaxAge(15 * time.Minute), jwt.Audience{"admin", "root"}) +func (aud Audience) ApplyClaims(dest *Claims) { + dest.Audience = aud +} + // Age returns the total age of the claims, // the result of issued at - expired time. func (c Claims) Age() time.Duration {