Gets the JWT from the client cookie. :return: String representing the ID token
()
| 67 | |
| 68 | |
| 69 | def get_decoded_id_token_from_session() -> str or None: |
| 70 | """ |
| 71 | Gets the JWT from the client cookie. |
| 72 | :return: String representing the ID token |
| 73 | """ |
| 74 | oidc = OAuth2Provider() |
| 75 | oidc_client = oidc.get_client() |
| 76 | id_token = login_session.get('id_token') |
| 77 | if id_token is None: |
| 78 | return None |
| 79 | |
| 80 | if type(id_token) == str: |
| 81 | token_string = id_token |
| 82 | expired = oidc_client.id_token_has_expired(id_token = token_string) |
| 83 | if expired: |
| 84 | token_string = try_refreshing_tokens() |
| 85 | return token_string |
| 86 | |
| 87 | # Case of compressed token (type is bytes) |
| 88 | token_string = gzip.decompress(id_token).decode() |
| 89 | expired = oidc_client.id_token_has_expired(id_token = token_string) |
| 90 | if expired: |
| 91 | token_string = try_refreshing_tokens() |
| 92 | |
| 93 | return token_string |
| 94 | |
| 95 | |
| 96 | def get_decoded_access_token_from_session() -> str or None: |
no test coverage detected