Skip to content

Commit 23edee2

Browse files
committed
revertme: add logging
1 parent a49881d commit 23edee2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

renku/ui/service/serializers/headers.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
from marshmallow import Schema, ValidationError, fields, post_load, pre_load
2525
from werkzeug.utils import secure_filename
2626

27+
from renku.ui.service.logger import service_log
28+
2729
JWT_TOKEN_SECRET = os.getenv("RENKU_JWT_TOKEN_SECRET", "bW9menZ3cnh6cWpkcHVuZ3F5aWJycmJn")
2830

2931

@@ -95,14 +97,18 @@ def decode_token(token):
9597
@staticmethod
9698
def decode_user(data):
9799
"""Extract renku user from the Keycloak ID token which is a JWT."""
100+
service_log.info(f"decoding token {data}")
98101
try:
99102
jwk = cast(jwt.PyJWKClient, current_app.config["KEYCLOAK_JWK_CLIENT"])
100103
key = jwk.get_signing_key_from_jwt(data)
104+
service_log.info(f"trying with key {key.key} and algo RS256")
101105
decoded = jwt.decode(data, key=key.key, algorithms=["RS256"], audience="renku")
102-
except jwt.PyJWTError:
106+
except jwt.PyJWTError as e:
103107
# NOTE: older tokens used to be signed with HS256 so use this as a backup if the validation with RS256
104108
# above fails. We used to need HS256 because a step that is now removed was generating an ID token and
105109
# signing it from data passed in individual header fields.
110+
service_log.info(f"original error {e}")
111+
service_log.info("trying with HS256")
106112
decoded = jwt.decode(data, JWT_TOKEN_SECRET, algorithms=["HS256"], audience="renku")
107113
return UserIdentityToken().load(decoded)
108114

0 commit comments

Comments
 (0)