
    k7i-                         S SK r 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K	J
r
  SSKJr  / S	Qr/ S
Qr " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      rS rS rg)    N)to_bytes)	JWTClaims)InvalidClaimError)MissingClaimError)scope_to_list   )create_half_hash)IDTokenCodeIDTokenImplicitIDTokenHybridIDTokenUserInfoget_claim_cls_by_response_type)isssubaudexpnbfiat	auth_timenonceacramrazpat_hashc                   J    \ 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g)r
   %   )r   r   r   r   r   Nc                 2   U R                    H  nX0;  d  M
  [        U5      e   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                  5         U R                  5         U R                  5         U R                  5         U R!                  5         g N)ESSENTIAL_CLAIMSr   _validate_essential_claimsinttimevalidate_issvalidate_subvalidate_audvalidate_expvalidate_nbfvalidate_iatvalidate_auth_timevalidate_noncevalidate_acrvalidate_amrvalidate_azpvalidate_at_hash)selfnowleewayks       R/home/james-whalen/.local/lib/python3.13/site-packages/authlib/oidc/core/claims.pyvalidateIDToken.validate(   s    &&A}'** ' 	'');diik"C#&#&#&!    c                     U R                  S5      nU R                  R                  S5      (       a  U(       d  [        S5      eU(       a'  [        U[        [
        45      (       d  [        S5      egg)aE  Time when the End-User authentication occurred. Its value is a JSON
number representing the number of seconds from 1970-01-01T0:0:0Z as
measured in UTC until the date/time. When a max_age request is made or
when auth_time is requested as an Essential Claim, then this Claim is
REQUIRED; otherwise, its inclusion is OPTIONAL.
r   max_ageN)getparamsr   
isinstancer"   floatr   )r0   r   s     r4   r*   IDToken.validate_auth_time>   sX     HH[)	;;??9%%i#K00Z	C<@@#K00 A9r7   c                     U R                   R                  S5      nU(       a%  SU ;  a  [        S5      eXS   :w  a  [        S5      egg)a  String value used to associate a Client session with an ID Token,
and to mitigate replay attacks. The value is passed through unmodified
from the Authentication Request to the ID Token. If present in the ID
Token, Clients MUST verify that the nonce Claim Value is equal to the
value of the nonce parameter sent in the Authentication Request. If
present in the Authentication Request, Authorization Servers MUST
include a nonce Claim in the ID Token with the Claim Value being the
nonce value sent in the Authentication Request. Authorization Servers
SHOULD perform no other processing on nonce values used. The nonce
value is a case sensitive string.
r   N)r;   r:   r   r   )r0   nonce_values     r4   r+   IDToken.validate_nonceL   sK     kkoog.d"'007m+'00 , r7   c                 $    U R                  S5      $ )a  OPTIONAL. Authentication Context Class Reference. String specifying
an Authentication Context Class Reference value that identifies the
Authentication Context Class that the authentication performed
satisfied. The value "0" indicates the End-User authentication did not
meet the requirements of `ISO/IEC 29115`_ level 1. Authentication
using a long-lived browser cookie, for instance, is one example where
the use of "level 0" is appropriate. Authentications with level 0
SHOULD NOT be used to authorize access to any resource of any monetary
value. An absolute URI or an `RFC 6711`_ registered name SHOULD be
used as the acr value; registered names MUST NOT be used with a
different meaning than that which is registered. Parties using this
claim will need to agree upon the meanings of the values used, which
may be context-specific. The acr value is a case sensitive string.

.. _`ISO/IEC 29115`: https://www.iso.org/standard/45138.html
.. _`RFC 6711`: https://tools.ietf.org/html/rfc6711
r   )_validate_claim_value)r0   s    r4   r,   IDToken.validate_acr_   s    $ ))%00r7   c                 |    U R                  S5      nU(       a$  [        U S   [        5      (       d  [        S5      egg)a  OPTIONAL. Authentication Methods References. JSON array of strings
that are identifiers for authentication methods used in the
authentication. For instance, values might indicate that both password
and OTP authentication methods were used. The definition of particular
values to be used in the amr Claim is beyond the scope of this
specification. Parties using this claim will need to agree upon the
meanings of the values used, which may be context-specific. The amr
value is an array of case sensitive strings.
r   N)r:   r<   listr   )r0   r   s     r4   r-   IDToken.validate_amrs   s6     hhuoz$u+t44#E** 53r7   c                 p   U R                  S5      nU R                  R                  S5      nSnU(       a7  U(       a0  [        U[        5      (       a  [	        U5      S:X  a  US   nX:w  a  SnU R                  S5      nU(       a  U(       d  [        S5      eU(       a  U(       a  XB:w  a  [        S5      eggg)	a  OPTIONAL. Authorized party - the party to which the ID Token was
issued. If present, it MUST contain the OAuth 2.0 Client ID of this
party. This Claim is only needed when the ID Token has a single
audience value and that audience is different than the authorized
party. It MAY be included even when the authorized party is the same
as the sole audience. The azp value is a case sensitive string
containing a StringOrURI value.
r   	client_idFr   r   Tr   N)r:   r;   r<   rF   lenr   r   )r0   r   rI   requiredr   s        r4   r.   IDToken.validate_azp   s     hhuoKKOOK0	9#t$$SQ!fhhuoC#E**9!1#E** "293r7   c                     U R                   R                  S5      nU R                  S5      nU(       a2  U(       a*  [        X!U R                  S   5      (       d  [	        S5      eggg)a  OPTIONAL. Access Token hash value. Its value is the base64url
encoding of the left-most half of the hash of the octets of the ASCII
representation of the access_token value, where the hash algorithm
used is the hash algorithm used in the alg Header Parameter of the
ID Token's JOSE Header. For instance, if the alg is RS256, hash the
access_token value with SHA-256, then take the left-most 128 bits and
base64url encode them. The at_hash value is a case sensitive string.
access_tokenr   algN)r;   r:   _verify_hashheaderr   )r0   rN   r   s      r4   r/   IDToken.validate_at_hash   sW     {{~6((9%|t{{57IJJ'	22 K $7r7    Nr   )__name__
__module____qualname____firstlineno__r    r5   r*   r+   r,   r-   r.   r/   __static_attributes__rS   r7   r4   r
   r
   %   s+    : ,11&1(++23r7   r
   c                       \ rS rSrSr\rSrg)r      )coderS   N)rU   rV   rW   rX   RESPONSE_TYPES_REGISTERED_CLAIMSREGISTERED_CLAIMSrY   rS   r7   r4   r   r      s    N*r7   r   c                   8   ^  \ rS rSrSr/ SQr\rU 4S jrSr	U =r
$ )r      )id_tokenzid_token token)r   r   r   r   r   r   c                    > U R                   R                  S5      nU(       a  SU ;  a  [        S5      e[        TU ]  5         g)a  If the ID Token is issued from the Authorization Endpoint with an
access_token value, which is the case for the response_type value
id_token token, this is REQUIRED; it MAY NOT be used when no Access
Token is issued, which is the case for the response_type value
id_token.
rN   r   N)r;   r:   r   superr/   )r0   rN   	__class__s     r4   r/    ImplicitIDToken.validate_at_hash   s7     {{~6IT1#I.. "r7   rS   )rU   rV   rW   rX   r]   r    r^   r_   r/   rY   __classcell__re   s   @r4   r   r      s    3NC*
# 
#r7   r   c                   B   ^  \ rS rSrSr\S/-   rSU 4S jjrS rSr	U =r
$ )r      )zcode id_tokenz
code tokenzcode id_token tokenc_hashc                 @   > [         TU ]  XS9  U R                  5         g )N)r1   r2   )rd   r5   validate_c_hash)r0   r1   r2   re   s      r4   r5   HybridIDToken.validate   s    S0r7   c                     U R                   R                  S5      nU R                  S5      nU(       a<  U(       d  [        S5      e[        X!U R                  S   5      (       d  [        S5      egg)a  Code hash value. Its value is the base64url encoding of the
left-most half of the hash of the octets of the ASCII representation
of the code value, where the hash algorithm used is the hash algorithm
used in the alg Header Parameter of the ID Token's JOSE Header. For
instance, if the alg is HS512, hash the code value with SHA-512, then
take the left-most 256 bits and base64url encode them. The c_hash
value is a case sensitive string.
If the ID Token is issued from the Authorization Endpoint with a code,
which is the case for the response_type values code id_token and code
id_token token, this is REQUIRED; otherwise, its inclusion is OPTIONAL.
r\   rk   rO   N)r;   r:   r   rP   rQ   r   )r0   r\   rk   s      r4   rm   HybridIDToken.validate_c_hash   sa     {{v&(#'11dkk%.@AA'11 B r7   rS   rT   )rU   rV   rW   rX   r]   r^   r_   r5   rm   rY   rg   rh   s   @r4   r   r      s$    KN*hZ72 2r7   r   c                   T    \ rS rSrSr/ SQrS// SQSS/S/S	S
/S.rS\4S jrS r	Sr
g)r      zThe standard claims of a UserInfo object. Defined per `Section 5.1`_.

.. _`Section 5.1`: http://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
)r   name
given_namefamily_namemiddle_namenicknamepreferred_usernameprofilepicturewebsiteemailemail_verifiedgender	birthdatezoneinfolocalephone_numberphone_number_verifiedaddress
updated_atr   )rs   ru   rt   rv   rw   rx   ry   rz   r{   r~   r   r   r   r   r|   r}   r   r   r   )openidry   r|   r   phonescopec                    [        U5      nU VVs/ s H)  nU R                  R                  U/ 5        H  nUPM     M+     nnnU R                  5        VVs0 s H  u  pVXT;   d  M  XV_M     nnn[	        U5      $ s  snnf s  snnf )z_Return a new UserInfo object containing only the claims matching the scope passed in parameter.)r   SCOPES_CLAIMS_MAPPINGr:   itemsr   )r0   r   
scope_partclaimfiltered_claimskeyvalfiltered_itemss           r4   filterUserInfo.filter  s    e$ $
#
3377
BG G # 	 
 &*ZZ\
%1S5KHCH\ 	 
 ''


s   0A:B &B 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__AttributeErrorr_   r:   )r0   r   errors      r4   __getattr__UserInfo.__getattr__   sG    	**455 	,,,xx}$K	s     
AA AAArS   N)rU   rV   rW   rX   __doc__r_   r   strr   r   rY   rS   r7   r4   r   r      sM    0 '
  +,; "9:).(C (r7   r   c                 ^    [         [        [        4nU H  nXR                  ;   d  M  Us  $    g r   )r   r   r   r]   )response_typeclaims_classes
claims_clss      r4   r   r   )  s*    !?MBN$
555 %r7   c                 h    [        X5      nU(       d  g[        R                  " U[        U 5      5      $ )NT)r	   hmaccompare_digestr   )	signaturesrO   
hash_values       r4   rP   rP   0  s*    !!)Jz8I+>??r7   )r   r#   authlib.common.encodingr   authlib.joser   authlib.jose.errorsr   r   authlib.oauth2.rfc6749.utilr   utilr	   __all__r^   r
   r   r   r   dictr   r   rP   rS   r7   r4   <module>r      sy      , " 1 1 5 "  B3i B3J+' +
#g #$2O 2:Ht HV@r7   