From 556f3e169e28da0f30b890c056593f60a7f713a8 Mon Sep 17 00:00:00 2001 From: Paul Marillonnet Date: Mon, 30 Mar 2020 11:46:14 +0200 Subject: [PATCH] auth_oidc: add id token 'as_dict' method (#37871) --- src/authentic2_auth_oidc/utils.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/authentic2_auth_oidc/utils.py b/src/authentic2_auth_oidc/utils.py index 26ef45708..898deb99f 100644 --- a/src/authentic2_auth_oidc/utils.py +++ b/src/authentic2_auth_oidc/utils.py @@ -127,6 +127,15 @@ class IDToken(object): _('Encoded ID Token must be either binary or string data')) self._encoded = encoded + def as_dict(self, provider, raises=False): + try: + parsed = parse_id_token(self._encoded, provider) + except JWException as e: + if raises: + raise IDTokenError(e) + parsed = {} + return parsed + def deserialize(self, provider): try: decoded = parse_id_token(self._encoded, provider)