@@ -159,6 +159,11 @@ def get_current_user(self) -> Participation | None:
159159 """
160160 cookie_name = self .contest .name + "_login"
161161 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 )
162167
163168 try :
164169 ip_address = ipaddress .ip_address (self .request .remote_ip )
@@ -170,7 +175,7 @@ def get_current_user(self) -> Participation | None:
170175 participation , cookie = authenticate_request (
171176 self .sql_session , self .contest ,
172177 self .timestamp , cookie ,
173- self . request . headers . get ( "X-CMS-Authorization" , None ) ,
178+ authorization_header ,
174179 ip_address )
175180
176181 if cookie is None :
@@ -309,6 +314,14 @@ def notify_warning(
309314 def notify_error (self , subject : str , text : str , text_params : object | None = None ):
310315 self .add_notification (subject , text , NOTIFICATION_ERROR , text_params )
311316
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+
312325
313326class FileHandler (ContestHandler , FileHandlerMixin ):
314327 pass
0 commit comments