Skip to content

Commit e3bb052

Browse files
committed
squashme: fix JWT validation
1 parent 4dc8568 commit e3bb052

File tree

1 file changed

+3
-27
lines changed

1 file changed

+3
-27
lines changed

renku/ui/service/serializers/headers.py

+3-27
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import jwt
2323
from flask import current_app
24-
from marshmallow import EXCLUDE, Schema, ValidationError, fields, post_load, pre_load
24+
from marshmallow import INCLUDE, Schema, ValidationError, fields, post_load, pre_load
2525
from werkzeug.utils import secure_filename
2626

2727
JWT_TOKEN_SECRET = os.getenv("RENKU_JWT_TOKEN_SECRET", "bW9menZ3cnh6cWpkcHVuZ3F5aWJycmJn")
@@ -48,37 +48,13 @@ class UserIdentityToken(Schema):
4848
"""User identity token schema."""
4949

5050
class Meta:
51-
unknown = EXCLUDE
52-
53-
jti = fields.String()
54-
exp = fields.Integer()
55-
nbf = fields.Integer()
56-
iat = fields.Integer()
57-
iss = fields.String()
58-
aud = fields.List(fields.String())
59-
sub = fields.String()
60-
typ = fields.String()
61-
azp = fields.String()
62-
nonce = fields.String()
63-
auth_time = fields.Integer()
64-
session_state = fields.String()
65-
acr = fields.String()
66-
email_verified = fields.Boolean()
67-
preferred_username = fields.String()
68-
given_name = fields.String()
69-
family_name = fields.String()
51+
unknown = INCLUDE
7052

53+
sub = fields.String(required=True)
7154
email = fields.String(required=True)
7255
name = fields.String(required=True)
7356
user_id = fields.String() # INFO: Generated post load.
7457

75-
@pre_load
76-
def make_audience_list(self, data, **kwargs):
77-
"""The aud claim in a token can be a list or a string if it is a single value."""
78-
aud = data.get("aud")
79-
if aud is not None and isinstance(data.get("aud"), str):
80-
data["aud"] = [data["aud"]]
81-
8258
@post_load
8359
def set_user_id(self, data, **kwargs):
8460
"""Sets users id."""

0 commit comments

Comments
 (0)