From 52981a5a9b400cac4d50469fec382ee544c1b70b Mon Sep 17 00:00:00 2001 From: Kevin Franklin Kim Date: Sat, 11 Jun 2022 18:21:19 +0200 Subject: [PATCH] fix: allow multiple calls --- jwt/jwt.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/jwt/jwt.go b/jwt/jwt.go index baba89b..de12ea2 100644 --- a/jwt/jwt.go +++ b/jwt/jwt.go @@ -26,11 +26,14 @@ func WithKeyFun(v jwt.Keyfunc) Option { // WithDeprecatedKeys middleware option func WithDeprecatedKeys(v ...Key) Option { return func(o *JWT) { - deprecatedKeys := make(map[string]Key, len(v)) - for _, key := range deprecatedKeys { - deprecatedKeys[key.ID] = key + if len(v) > 0 { + if o.DeprecatedKeys == nil { + o.DeprecatedKeys = map[string]Key{} + } + for _, key := range v { + o.DeprecatedKeys[key.ID] = key + } } - o.DeprecatedKeys = deprecatedKeys } }