puiterwijk/flask-oidc

Uncaught ValueError thrown when credentials_store is missing a key

gfinak opened this issue · 0 comments

We are using flask-oidc 1.4.
There this bug occurs at lines 457-465.

When the credentials store has no key for id_token["sub"] this throws an uncaught ValueError as line 443 returns None.

# when Google is the IdP, this happens after one hour
if time.time() >= id_token['exp']:
# get credentials from store
try:
credentials = OAuth2Credentials.from_json(
self.credentials_store[id_token['sub']])
except KeyError:
logger.debug("Expired ID token, credentials missing",
exc_info=True)
return self.redirect_to_auth_server(request.url)

Simply catching the error and redirecting solves the issue.

except ValueError:
                logger.debug("Credentials missing", exc_info=True)
                return self.redirect_to_auth_server(request.url)