
    k7iO"                     n    S SK r S SKJr  S SKJr  S SKJr  S SKJr   " S S\5      r " S S	\5      rS
 r	g)    N)ExpiredTokenError)InvalidClaimError)InvalidTokenError)MissingClaimErrorc                   L   ^  \ rS rSrSr/ rS	U 4S jjrS rS rS r	S r
SrU =r$ )

BaseClaims	   a  Payload claims for JWT, which contains a validate interface.

:param payload: the payload dict of JWT
:param header: the header dict of JWT
:param options: validate options
:param params: other params

An example on ``options`` parameter, the format is inspired by
`OpenID Connect Claims`_::

    {
        "iss": {
            "essential": True,
            "values": ["https://example.com", "https://example.org"]
        },
        "sub": {
            "essential": True
            "value": "248289761001"
        },
        "jti": {
            "validate": validate_jti
        }
    }

.. _`OpenID Connect Claims`:
    http://openid.net/specs/openid-connect-core-1_0.html#IndividualClaimsRequests
c                 p   > [         TU ]  U5        X l        U=(       d    0 U l        U=(       d    0 U l        g N)super__init__headeroptionsparams)selfpayloadr   r   r   	__class__s        U/home/james-whalen/.local/lib/python3.13/site-packages/authlib/jose/rfc7519/claims.pyr   BaseClaims.__init__(   s+    !}"l    c                      [         R                  X5      $ ! [         a,  nXR                  ;   a  U R	                  U5      s S nA$ UeS nAff = fr   )object__getattribute__AttributeErrorREGISTERED_CLAIMSget)r   keyerrors      r   __getattr__BaseClaims.__getattr__.   sG    	**455 	,,,xx}$K	s     
AA AAAc                     U R                    HY  nU R                   U   R                  S5      (       d  M(  X;  a  [        U5      eU R                  U5      (       a  MP  [        U5      e   g )N	essential)r   r   r   r   )r   ks     r   _validate_essential_claims%BaseClaims._validate_essential_claims6   sQ    A||A"";//=+A..!+A.. r   c                 n   U R                   R                  U5      nU(       d  g U R                  U5      nUR                  S5      nU(       a  X4:w  a  [        U5      eUR                  S5      nU(       a  X5;  a  [        U5      eUR                  S5      nU(       a  U" X5      (       d  [        U5      eg g )Nvaluevaluesvalidate)r   r   r   )r   
claim_nameoptionr'   option_valueoption_valuesr)   s          r   _validate_claim_value BaseClaims._validate_claim_value>   s    !!*-$zz'*E1#J//

8,U7#J//::j)HT11#J// 28r   c                 J    0 nU R                    H  nX ;   d  M
  X   X'   M     U$ r   )r   )r   rvr#   s      r   get_registered_claims BaseClaims.get_registered_claimsP   s,    ''Ay ( 	r   )r   r   r   )NN)__name__
__module____qualname____firstlineno____doc__r   r   r   r$   r.   r2   __static_attributes____classcell__)r   s   @r   r   r   	   s.    8 #/0$ r   r   c                   P    \ rS rSr/ SQrSS jrS rS rS rS r	S	 r
S
 rS rSrg)	JWTClaimsX   )isssubaudexpnbfiatjtiNc                    U R                  5         Uc  [        [        R                  " 5       5      nU R                  5         U R	                  5         U R                  5         U R                  X5        U R                  X5        U R                  X5        U R                  5         U R                  R                  5        H%  nX0R                  ;  d  M  U R                  U5        M'     g)z&Validate everything in claims payload.N)r$   inttimevalidate_issvalidate_subvalidate_audvalidate_expvalidate_nbfvalidate_iatvalidate_jtir   keysr   r.   )r   nowleewayr   s       r   r)   JWTClaims.validate[   s    '');diik"C#&#&#& <<$$&C000**3/ 'r   c                 &    U R                  S5        g)zThe "iss" (issuer) claim identifies the principal that issued the
JWT.  The processing of this claim is generally application specific.
The "iss" value is a case-sensitive string containing a StringOrURI
value.  Use of this claim is OPTIONAL.
r>   Nr.   r   s    r   rH   JWTClaims.validate_isso   s     	""5)r   c                 &    U R                  S5        g)a  The "sub" (subject) claim identifies the principal that is the
subject of the JWT.  The claims in a JWT are normally statements
about the subject.  The subject value MUST either be scoped to be
locally unique in the context of the issuer or be globally unique.
The processing of this claim is generally application specific.  The
"sub" value is a case-sensitive string containing a StringOrURI
value.  Use of this claim is OPTIONAL.
r?   NrT   rU   s    r   rI   JWTClaims.validate_subw   s     	""5)r   c                    U R                   R                  S5      nU R                  S5      nU(       a  U(       d  gUR                  S5      nU(       d  UR                  S5      nU(       a  U/nU(       d  g[        U S   [        5      (       a  U S   nOU S   /n[	        U Vs/ s H  ofU;   PM	     sn5      (       d  [        S5      egs  snf )a  The "aud" (audience) claim identifies the recipients that the JWT is
intended for.  Each principal intended to process the JWT MUST
identify itself with a value in the audience claim.  If the principal
processing the claim does not identify itself with a value in the
"aud" claim when this claim is present, then the JWT MUST be
rejected.  In the general case, the "aud" value is an array of case-
sensitive strings, each containing a StringOrURI value.  In the
special case when the JWT has one audience, the "aud" value MAY be a
single case-sensitive string containing a StringOrURI value.  The
interpretation of audience values is generally application specific.
Use of this claim is OPTIONAL.
r@   Nr(   r'   )r   r   
isinstancelistanyr   )r   
aud_optionr@   
aud_values	aud_valueaud_listvs          r   rJ   JWTClaims.validate_aud   s     \\%%e,
hhuo^^H-
"w/I'[
d5k4((E{HU}H:6:aM:677#E** 86s   $C
c                 v    SU ;   a3  U S   n[        U5      (       d  [        S5      eX1U-
  :  a
  [        5       egg)a  The "exp" (expiration time) claim identifies the expiration time on
or after which the JWT MUST NOT be accepted for processing.  The
processing of the "exp" claim requires that the current date/time
MUST be before the expiration date/time listed in the "exp" claim.
Implementers MAY provide for some small leeway, usually no more than
a few minutes, to account for clock skew.  Its value MUST be a number
containing a NumericDate value.  Use of this claim is OPTIONAL.
rA   N)_validate_numeric_timer   r   )r   rP   rQ   rA   s       r   rK   JWTClaims.validate_exp   G     D=u+C)#..'..Fl#')) $	 r   c                 v    SU ;   a3  U S   n[        U5      (       d  [        S5      eX1U-   :  a
  [        5       egg)a  The "nbf" (not before) claim identifies the time before which the JWT
MUST NOT be accepted for processing.  The processing of the "nbf"
claim requires that the current date/time MUST be after or equal to
the not-before date/time listed in the "nbf" claim.  Implementers MAY
provide for some small leeway, usually no more than a few minutes, to
account for clock skew.  Its value MUST be a number containing a
NumericDate value.  Use of this claim is OPTIONAL.
rB   Nrd   r   r   )r   rP   rQ   rB   s       r   rL   JWTClaims.validate_nbf   rf   r   c                 t    SU ;   a2  U S   n[        U5      (       d  [        S5      eX1U-   :  a	  [        SS9egg)aP  The "iat" (issued at) claim identifies the time at which the JWT was
issued.  This claim can be used to determine the age of the JWT.
Implementers MAY provide for some small leeway, usually no more
than a few minutes, to account for clock skew. Its value MUST be a
number containing a NumericDate value.  Use of this claim is OPTIONAL.
rC   z5The token is not valid as it was issued in the future)descriptionNrh   )r   rP   rQ   rC   s       r   rM   JWTClaims.validate_iat   sN     D=u+C)#..'..Fl#' W  $	 r   c                 &    U R                  S5        g)a  The "jti" (JWT ID) claim provides a unique identifier for the JWT.
The identifier value MUST be assigned in a manner that ensures that
there is a negligible probability that the same value will be
accidentally assigned to a different data object; if the application
uses multiple issuers, collisions MUST be prevented among values
produced by different issuers as well.  The "jti" claim can be used
to prevent the JWT from being replayed.  The "jti" value is a case-
sensitive string.  Use of this claim is OPTIONAL.
rD   NrT   rU   s    r   rN   JWTClaims.validate_jti   s     	""5)r    )Nr   )r4   r5   r6   r7   r   r)   rH   rI   rJ   rK   rL   rM   rN   r9   ro   r   r   r<   r<   X   s1    I0(*	*!+F* *  
*r   r<   c                 .    [        U [        [        45      $ r   )rZ   rF   float)ss    r   rd   rd      s    a#u&&r   )
rG   authlib.jose.errorsr   r   r   r   dictr   r<   rd   ro   r   r   <module>ru      s7     1 1 1 1L L^G*
 G*T'r   