@@ -159,6 +159,11 @@ def get_current_user(self) -> Participation | None:
159
159
"""
160
160
cookie_name = self .contest .name + "_login"
161
161
cookie = self .get_secure_cookie (cookie_name )
162
+ authorization_header = self .request .headers .get (
163
+ "X-CMS-Authorization" , None )
164
+ if authorization_header is not None :
165
+ authorization_header = tornado_web .decode_signed_value (self .application .settings ["cookie_secret" ],
166
+ cookie_name , authorization_header )
162
167
163
168
try :
164
169
ip_address = ipaddress .ip_address (self .request .remote_ip )
@@ -170,7 +175,7 @@ def get_current_user(self) -> Participation | None:
170
175
participation , cookie = authenticate_request (
171
176
self .sql_session , self .contest ,
172
177
self .timestamp , cookie ,
173
- self . request . headers . get ( "X-CMS-Authorization" , None ) ,
178
+ authorization_header ,
174
179
ip_address )
175
180
176
181
if cookie is None :
@@ -309,6 +314,14 @@ def notify_warning(
309
314
def notify_error (self , subject : str , text : str , text_params : object | None = None ):
310
315
self .add_notification (subject , text , NOTIFICATION_ERROR , text_params )
311
316
317
+ def check_xsrf_cookie (self ):
318
+ # We don't need to check for xsrf if the request came with a custom
319
+ # header, as those are not set by the browser.
320
+ if "X-CMS-Authorization" in self .request .headers :
321
+ pass
322
+ else :
323
+ super ().check_xsrf_cookie ()
324
+
312
325
313
326
class FileHandler (ContestHandler , FileHandlerMixin ):
314
327
pass
0 commit comments