From 6dc2003e340ca25efa4a00374347a08e8dc375b3 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 22 Dec 2021 23:00:57 +0100 Subject: [PATCH] providers/oauth2: fix tests validating JWT incorrectly Signed-off-by: Jens Langhammer --- authentik/providers/oauth2/tests/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/authentik/providers/oauth2/tests/utils.py b/authentik/providers/oauth2/tests/utils.py index 3b846a1b7..6c36dee17 100644 --- a/authentik/providers/oauth2/tests/utils.py +++ b/authentik/providers/oauth2/tests/utils.py @@ -2,7 +2,7 @@ from django.test import TestCase from jwt import decode -from authentik.providers.oauth2.models import OAuth2Provider, RefreshToken +from authentik.providers.oauth2.models import JWTAlgorithms, OAuth2Provider, RefreshToken class OAuthTestCase(TestCase): @@ -20,6 +20,8 @@ class OAuthTestCase(TestCase): def validate_jwt(self, token: RefreshToken, provider: OAuth2Provider): """Validate that all required fields are set""" key, alg = provider.get_jwt_key() + if alg != JWTAlgorithms.HS256: + key = provider.signing_key.public_key jwt = decode( token.access_token, key,