Skip to content

Commit 2412865

Browse files
committed
fix(jwt): allow large token in response, but limit large token in cookie. Closes #115
1 parent 03c5898 commit 2412865

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

users/views.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,13 +1063,14 @@ def arena_token(request):
10631063
response = JsonResponse(data)
10641064
# Careful of token size in cookie:
10651065
# RFC 6265 states that user agents should support cookies of at least 4096 bytes. For many browsers this is also the maximum size. Django will not raise an exception if there’s an attempt to store a cookie of more than 4096 bytes, but many browsers will not set the cookie correctly.
1066-
response.set_cookie(
1067-
"mqtt_token",
1068-
token,
1069-
max_age=86400000,
1070-
httponly=True,
1071-
secure=True,
1072-
)
1066+
if len(token) < 4096:
1067+
response.set_cookie(
1068+
"mqtt_token",
1069+
token,
1070+
max_age=86400000,
1071+
httponly=True,
1072+
secure=True,
1073+
)
10731074
return response
10741075

10751076

0 commit comments

Comments
 (0)