Skip to content

Commit c93d276

Browse files
committed
revertme: add logging
1 parent 4dc8568 commit c93d276

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 EXCLUDE, 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

@@ -105,14 +107,18 @@ def decode_token(token):
105107
@staticmethod
106108
def decode_user(data):
107109
"""Extract renku user from the Keycloak ID token which is a JWT."""
110+
service_log.info(f"decoding token {data}")
108111
try:
109112
jwk = cast(jwt.PyJWKClient, current_app.config["KEYCLOAK_JWK_CLIENT"])
110113
key = jwk.get_signing_key_from_jwt(data)
114+
service_log.info(f"trying with key {key.key} and algo RS256")
111115
decoded = jwt.decode(data, key=key.key, algorithms=["RS256"], audience="renku")
112-
except jwt.PyJWTError:
116+
except jwt.PyJWTError as e:
113117
# NOTE: older tokens used to be signed with HS256 so use this as a backup if the validation with RS256
114118
# above fails. We used to need HS256 because a step that is now removed was generating an ID token and
115119
# signing it from data passed in individual header fields.
120+
service_log.info(f"original error {e}")
121+
service_log.info("trying with HS256")
116122
decoded = jwt.decode(data, JWT_TOKEN_SECRET, algorithms=["HS256"], audience="renku")
117123
return UserIdentityToken().load(decoded)
118124

0 commit comments

Comments
 (0)