fallback to olde keys if failing to fetch refreshed keys

This commit is contained in:
Bethuel 2023-04-21 13:34:52 +03:00
parent 90c8cfd863
commit 45224e76d0

View File

@ -101,11 +101,14 @@ func NewJWTValidator(issuer string, audienceList []string, keysLocation string,
if !keys.stillValid() { if !keys.stillValid() {
lock.Lock() lock.Lock()
defer lock.Unlock() defer lock.Unlock()
keys, err = getPemKeys(keysLocation)
refreshedKeys, err := getPemKeys(keysLocation)
if err != nil { if err != nil {
log.Debugf("cannot get JSONWebKey: %v", err) log.Debugf("cannot get JSONWebKey: %v, falling back to old keys", err)
return nil, err refreshedKeys = keys
} }
keys = refreshedKeys
} }
} }