@@ -484,13 +484,11 @@ def unset_refresh_cookies(self,response: Optional[Response] = None) -> None:
484
484
domain = self ._cookie_domain
485
485
)
486
486
487
- def _verify_and_get_jwt_optional_in_cookies (self , issuer : Optional [ str ] = None ) -> "AuthJWT" :
487
+ def _verify_and_get_jwt_optional_in_cookies (self ) -> "AuthJWT" :
488
488
"""
489
489
Optionally check if cookies have a valid access token. if an access token present in
490
490
cookies property _token will set. raises exception error when an access token is invalid
491
491
and doesn't match with CSRF token double submit
492
-
493
- :param issuer: expected issuer in the JWT
494
492
"""
495
493
cookie_key = self ._access_cookie_key
496
494
cookie = self ._request .cookies .get (cookie_key )
@@ -506,7 +504,7 @@ def _verify_and_get_jwt_optional_in_cookies(self,issuer: Optional[str] = None) -
506
504
507
505
# set token from cookie and verify jwt
508
506
self ._token = cookie
509
- self .verify_jwt_optional_in_request (self ._token , issuer )
507
+ self .verify_jwt_optional_in_request (self ._token )
510
508
511
509
decoded_token = self .get_raw_jwt ()
512
510
@@ -524,7 +522,6 @@ def _verify_and_get_jwt_optional_in_cookies(self,issuer: Optional[str] = None) -
524
522
def _verify_and_get_jwt_in_cookies (
525
523
self ,
526
524
type_token : str ,
527
- issuer : Optional [str ] = None ,
528
525
fresh : Optional [bool ] = False
529
526
) -> "AuthJWT" :
530
527
"""
@@ -533,7 +530,6 @@ def _verify_and_get_jwt_in_cookies(
533
530
is invalid and doesn't match with CSRF token double submit
534
531
535
532
:param type_token: indicate token is access or refresh token
536
- :param issuer: expected issuer in the JWT
537
533
:param fresh: check freshness token if True
538
534
"""
539
535
if type_token == 'access' :
@@ -553,7 +549,7 @@ def _verify_and_get_jwt_in_cookies(
553
549
554
550
# set token from cookie and verify jwt
555
551
self ._token = cookie
556
- self .verify_jwt_in_request (self ._token ,type_token ,'cookies' ,issuer , fresh )
552
+ self .verify_jwt_in_request (self ._token ,type_token ,'cookies' ,fresh )
557
553
558
554
decoded_token = self .get_raw_jwt ()
559
555
@@ -563,15 +559,14 @@ def _verify_and_get_jwt_in_cookies(
563
559
if not hmac .compare_digest (csrf_cookie ,decoded_token ['csrf' ]):
564
560
raise CSRFError (status_code = 401 ,message = "CSRF double submit tokens do not match" )
565
561
566
- def verify_jwt_optional_in_request (self ,token : str , issuer : Optional [ str ] = None ) -> None :
562
+ def verify_jwt_optional_in_request (self ,token : str ) -> None :
567
563
"""
568
564
Optionally check if this request has a valid access token
569
565
570
566
:param token: The encoded JWT
571
- :param issuer: expected issuer in the JWT
572
567
"""
573
568
if token :
574
- self ._verifying_token (token , issuer )
569
+ self ._verifying_token (token )
575
570
576
571
if token and self .get_raw_jwt (token )['type' ] != 'access' :
577
572
raise AccessTokenRequired (status_code = 422 ,message = "Only access tokens are allowed" )
@@ -581,7 +576,6 @@ def verify_jwt_in_request(
581
576
token : str ,
582
577
type_token : str ,
583
578
token_from : str ,
584
- issuer : Optional [str ] = None ,
585
579
fresh : Optional [bool ] = False
586
580
) -> None :
587
581
"""
@@ -590,9 +584,10 @@ def verify_jwt_in_request(
590
584
:param token: The encoded JWT
591
585
:param type_token: indicate token is access or refresh token
592
586
:param token_from: indicate token from headers or cookies
593
- :param issuer: expected issuer in the JWT
594
587
:param fresh: check freshness token if True
595
588
"""
589
+ issuer = self ._decode_issuer if type_token == 'access' else None
590
+
596
591
if token :
597
592
self ._verifying_token (token ,issuer )
598
593
@@ -659,14 +654,14 @@ def jwt_required(self) -> None:
659
654
"""
660
655
if len (self ._token_location ) == 2 :
661
656
if self ._token and self .jwt_in_headers :
662
- self .verify_jwt_in_request (self ._token ,'access' ,'headers' , self . _decode_issuer )
657
+ self .verify_jwt_in_request (self ._token ,'access' ,'headers' )
663
658
if not self ._token and self .jwt_in_cookies :
664
- self ._verify_and_get_jwt_in_cookies ('access' , self . _decode_issuer )
659
+ self ._verify_and_get_jwt_in_cookies ('access' )
665
660
else :
666
661
if self .jwt_in_headers :
667
- self .verify_jwt_in_request (self ._token ,'access' ,'headers' , self . _decode_issuer )
662
+ self .verify_jwt_in_request (self ._token ,'access' ,'headers' )
668
663
if self .jwt_in_cookies :
669
- self ._verify_and_get_jwt_in_cookies ('access' , self . _decode_issuer )
664
+ self ._verify_and_get_jwt_in_cookies ('access' )
670
665
671
666
def jwt_optional (self ) -> None :
672
667
"""
@@ -676,14 +671,14 @@ def jwt_optional(self) -> None:
676
671
"""
677
672
if len (self ._token_location ) == 2 :
678
673
if self ._token and self .jwt_in_headers :
679
- self .verify_jwt_optional_in_request (self ._token , self . _decode_issuer )
674
+ self .verify_jwt_optional_in_request (self ._token )
680
675
if not self ._token and self .jwt_in_cookies :
681
- self ._verify_and_get_jwt_optional_in_cookies (self . _decode_issuer )
676
+ self ._verify_and_get_jwt_optional_in_cookies ()
682
677
else :
683
678
if self .jwt_in_headers :
684
- self .verify_jwt_optional_in_request (self ._token , self . _decode_issuer )
679
+ self .verify_jwt_optional_in_request (self ._token )
685
680
if self .jwt_in_cookies :
686
- self ._verify_and_get_jwt_optional_in_cookies (self . _decode_issuer )
681
+ self ._verify_and_get_jwt_optional_in_cookies ()
687
682
688
683
def jwt_refresh_token_required (self ) -> None :
689
684
"""
@@ -706,14 +701,14 @@ def fresh_jwt_required(self) -> None:
706
701
"""
707
702
if len (self ._token_location ) == 2 :
708
703
if self ._token and self .jwt_in_headers :
709
- self .verify_jwt_in_request (self ._token ,'access' ,'headers' ,self . _decode_issuer , True )
704
+ self .verify_jwt_in_request (self ._token ,'access' ,'headers' ,True )
710
705
if not self ._token and self .jwt_in_cookies :
711
- self ._verify_and_get_jwt_in_cookies ('access' ,self . _decode_issuer , True )
706
+ self ._verify_and_get_jwt_in_cookies ('access' ,True )
712
707
else :
713
708
if self .jwt_in_headers :
714
- self .verify_jwt_in_request (self ._token ,'access' ,'headers' ,self . _decode_issuer , True )
709
+ self .verify_jwt_in_request (self ._token ,'access' ,'headers' ,True )
715
710
if self .jwt_in_cookies :
716
- self ._verify_and_get_jwt_in_cookies ('access' ,self . _decode_issuer , True )
711
+ self ._verify_and_get_jwt_in_cookies ('access' ,True )
717
712
718
713
def get_raw_jwt (self ,encoded_token : Optional [str ] = None ) -> Optional [Dict [str ,Union [str ,int ,bool ]]]:
719
714
"""
0 commit comments