@@ -369,7 +369,7 @@ def sign_request(self, method: str, url_params: str, headers: dict, data: Option
369369 if "NC-USER-ID" in sign_headers :
370370 headers ["NC-USER-ID" ] = sign_headers ["NC-USER-ID" ]
371371
372- def sign_check (self , request : Request ):
372+ def sign_check (self , request : Request ) -> None :
373373 current_time = int (datetime .now (timezone .utc ).timestamp ())
374374 headers = {
375375 "AE-VERSION" : request .headers .get ("AE-VERSION" , "" ),
@@ -386,8 +386,9 @@ def sign_check(self, request: Request):
386386 if empty_headers :
387387 raise ValueError (f"Missing required headers:{ empty_headers } " )
388388
389- if headers ["EX-APP-VERSION" ] != self .adapter .headers .get ("EX-APP-VERSION" ):
390- pass # TO-DO: we should reject all requests and ask server to update our app version
389+ our_version = self .adapter .headers .get ("EX-APP-VERSION" , "" )
390+ if headers ["EX-APP-VERSION" ] != our_version :
391+ raise ValueError (f"Invalid EX-APP-VERSION:{ headers ['EX-APP-VERSION' ]} <=> { our_version } " )
391392
392393 request_time = int (headers ["AE-SIGN-TIME" ])
393394 if request_time < current_time - 5 * 60 or request_time > current_time + 5 * 60 :
@@ -411,4 +412,3 @@ def sign_check(self, request: Request):
411412 raise ValueError (f"Invalid AE-DATA-HASH:{ ae_data_hash } !={ headers ['AE-DATA-HASH' ]} " )
412413 if headers ["EX-APP-ID" ] != self .cfg .app_name :
413414 raise ValueError (f"Invalid EX-APP-ID:{ headers ['EX-APP-ID' ]} != { self .cfg .app_name } " )
414- return True
0 commit comments