
    k7iD                     J    S SK Jr  S SKJr  S SKJr   " S S\5      rS rS rg)	    )is_secure_transport)is_valid_url)urlparsec                       \ rS rSrSr/ SQrS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r\S 5       r\S 5       r\S 5       r\S 5       r \S 5       r!S r"S  r#S!r$g")#AuthorizationServerMetadata   zDefine Authorization Server Metadata via `Section 2`_ in RFC8414_.

.. _RFC8414: https://tools.ietf.org/html/rfc8414
.. _`Section 2`: https://tools.ietf.org/html/rfc8414#section-2
)issuerauthorization_endpointtoken_endpointjwks_uriregistration_endpointscopes_supportedresponse_types_supportedresponse_modes_supportedgrant_types_supported%token_endpoint_auth_methods_supported0token_endpoint_auth_signing_alg_values_supportedservice_documentationui_locales_supportedop_policy_uri
op_tos_urirevocation_endpoint*revocation_endpoint_auth_methods_supported5revocation_endpoint_auth_signing_alg_values_supportedintrospection_endpoint-introspection_endpoint_auth_methods_supported8introspection_endpoint_auth_signing_alg_values_supported code_challenge_methods_supportedc                    U R                  S5      nU(       d  [        S5      e[        R                  " U5      n[        U5      (       d  [        S5      eUR                  (       d  UR
                  (       a  [        S5      eg)zREQUIRED. The authorization server's issuer identifier, which is
a URL that uses the "https" scheme and has no query or fragment
components.
r	   z"issuer" is requiredz "issuer" MUST use "https" schemez!"issuer" has no query or fragmentN)get
ValueErrorr   r   queryfragment)selfr	   parseds      W/home/james-whalen/.local/lib/python3.13/site-packages/authlib/oauth2/rfc8414/models.pyvalidate_issuer+AuthorizationServerMetadata.validate_issuer&   sl    
 (# 344""6* #6**?@@ <<6??@AA +    c                     U R                  S5      nU(       a  [        U5      (       d  [        S5      eg[        U R                  5      nSS1nX#-  (       a  [        S5      eg)zURL of the authorization server's authorization endpoint
[RFC6749]. This is REQUIRED unless no grant types are supported
that use the authorization endpoint.
r
   z0"authorization_endpoint" MUST use "https" schemeNauthorization_codeimplicitz$"authorization_endpoint" is required)r    r   r!   setr   )r$   urlr   authorization_grant_typess       r&   validate_authorization_endpoint;AuthorizationServerMetadata.validate_authorization_endpoint;   sc    
 hh/0&s++ !STT #D$>$> ?%9:$F! <CDD =r)   c                     U R                  S5      nU(       a  [        U5      S:X  a
  US   S:X  a  gU R                  S5      nU(       d  [        S5      e[        U5      (       d  [        S5      eg)	zURL of the authorization server's token endpoint [RFC6749]. This
is REQUIRED unless only the implicit grant type is supported.
r      r   r,   Nr   z"token_endpoint" is requiredz("token_endpoint" MUST use "https" scheme)r    lenr!   r   )r$   r   r.   s      r&   validate_token_endpoint3AuthorizationServerMetadata.validate_token_endpointK   so     !%)@ A!)*a/%a(J6hh'(;<<"3''GHH (r)   c                 l    U R                  S5      nU(       a  [        U5      (       d  [        S5      egg)a$  OPTIONAL.  URL of the authorization server's JWK Set [JWK]
document.  The referenced document contains the signing key(s) the
client uses to validate signatures from the authorization server.
This URL MUST use the "https" scheme.  The JWK Set MAY also
contain the server's encryption key or keys, which are used by
clients to encrypt requests to the server.  When both signing and
encryption keys are made available, a "use" (public key use)
parameter value is REQUIRED for all keys in the referenced JWK Set
to indicate each key's intended usage.
r   z""jwks_uri" MUST use "https" schemeNr    r   r!   r$   r.   s     r&   validate_jwks_uri-AuthorizationServerMetadata.validate_jwks_uri^   s3     hhz"*3//ABB 03r)   c                 l    U R                  S5      nU(       a  [        U5      (       d  [        S5      egg)zgOPTIONAL.  URL of the authorization server's OAuth 2.0 Dynamic
Client Registration endpoint [RFC7591].
r   z/"registration_endpoint" MUST use "https" schemeNr8   r9   s     r&   validate_registration_endpoint:AuthorizationServerMetadata.validate_registration_endpointm   s4     hh./*3//NOO 03r)   c                     [        U S5        g)zRECOMMENDED. JSON array containing a list of the OAuth 2.0
[RFC6749] "scope" values that this authorization server supports.
Servers MAY choose not to advertise some supported scope values
even when this parameter is used.
r   Nvalidate_array_valuer$   s    r&   validate_scopes_supported5AuthorizationServerMetadata.validate_scopes_supportedu   s     	T#56r)   c                     U R                  S5      nU(       d  [        S5      e[        U[        5      (       d  [        S5      eg)a  REQUIRED.  JSON array containing a list of the OAuth 2.0
"response_type" values that this authorization server supports.
The array values used are the same as those used with the
"response_types" parameter defined by "OAuth 2.0 Dynamic Client
Registration Protocol" [RFC7591].
r   z&"response_types_supported" is requiredz-"response_types_supported" MUST be JSON arrayN)r    r!   
isinstancelist)r$   r   s     r&   !validate_response_types_supported=AuthorizationServerMetadata.validate_response_types_supported}   sB     $(88,F#G 'EFF2D99LMM :r)   c                     [        U S5        g)aq  OPTIONAL.  JSON array containing a list of the OAuth 2.0
"response_mode" values that this authorization server supports, as
specified in "OAuth 2.0 Multiple Response Type Encoding Practices"
[OAuth.Responses].  If omitted, the default is "["query",
"fragment"]".  The response mode value "form_post" is also defined
in "OAuth 2.0 Form Post Response Mode" [OAuth.Post].
r   Nr@   rB   s    r&   !validate_response_modes_supported=AuthorizationServerMetadata.validate_response_modes_supported   s     	T#=>r)   c                     [        U S5        g)aU  OPTIONAL. JSON array containing a list of the OAuth 2.0 grant
type values that this authorization server supports.  The array
values used are the same as those used with the "grant_types"
parameter defined by "OAuth 2.0 Dynamic Client Registration
Protocol" [RFC7591].  If omitted, the default value is
"["authorization_code", "implicit"]".
r   Nr@   rB   s    r&   validate_grant_types_supported:AuthorizationServerMetadata.validate_grant_types_supported   s     	T#:;r)   c                     [        U S5        g)aw  OPTIONAL.  JSON array containing a list of client authentication
methods supported by this token endpoint.  Client authentication
method values are used in the "token_endpoint_auth_method"
parameter defined in Section 2 of [RFC7591].  If omitted, the
default is "client_secret_basic" -- the HTTP Basic Authentication
Scheme specified in Section 2.3.1 of OAuth 2.0 [RFC6749].
r   Nr@   rB   s    r&   .validate_token_endpoint_auth_methods_supportedJAuthorizationServerMetadata.validate_token_endpoint_auth_methods_supported   s     	T#JKr)   c                 2    [        U SU R                  5        g)a-  OPTIONAL.  JSON array containing a list of the JWS signing
algorithms ("alg" values) supported by the token endpoint for the
signature on the JWT [JWT] used to authenticate the client at the
token endpoint for the "private_key_jwt" and "client_secret_jwt"
authentication methods.  This metadata entry MUST be present if
either of these authentication methods are specified in the
"token_endpoint_auth_methods_supported" entry.  No default
algorithms are implied if this entry is omitted.  Servers SHOULD
support "RS256".  The value "none" MUST NOT be used.
r   N)_validate_alg_valuesr   rB   s    r&   9validate_token_endpoint_auth_signing_alg_values_supportedUAuthorizationServerMetadata.validate_token_endpoint_auth_signing_alg_values_supported   s     	>66	
r)   c                 l    U R                  S5      nU(       a  [        U5      (       d  [        S5      egg)a@  OPTIONAL. URL of a page containing human-readable information
that developers might want or need to know when using the
authorization server.  In particular, if the authorization server
does not support Dynamic Client Registration, then information on
how to register clients needs to be provided in this
documentation.
r   z%"service_documentation" MUST be a URLNr    r   r!   r$   values     r&   validate_service_documentation:AuthorizationServerMetadata.validate_service_documentation   s3     01e,,DEE -5r)   c                     [        U S5        g)zOPTIONAL.  Languages and scripts supported for the user interface,
represented as a JSON array of language tag values from BCP 47
[RFC5646].  If omitted, the set of supported languages and scripts
is unspecified.
r   Nr@   rB   s    r&   validate_ui_locales_supported9AuthorizationServerMetadata.validate_ui_locales_supported   s     	T#9:r)   c                 l    U R                  S5      nU(       a  [        U5      (       d  [        S5      egg)a"  OPTIONAL.  URL that the authorization server provides to the
person registering the client to read about the authorization
server's requirements on how the client can use the data provided
by the authorization server.  The registration process SHOULD
display this URL to the person registering the client if it is
given.  As described in Section 5, despite the identifier
"op_policy_uri" appearing to be OpenID-specific, its usage in this
specification is actually referring to a general OAuth 2.0 feature
that is not specific to OpenID Connect.
r   z"op_policy_uri" MUST be a URLNrX   rY   s     r&   validate_op_policy_uri2AuthorizationServerMetadata.validate_op_policy_uri   s2     )e,,<== -5r)   c                 l    U R                  S5      nU(       a  [        U5      (       d  [        S5      egg)a  OPTIONAL.  URL that the authorization server provides to the
person registering the client to read about the authorization
server's terms of service.  The registration process SHOULD
display this URL to the person registering the client if it is
given.  As described in Section 5, despite the identifier
"op_tos_uri", appearing to be OpenID-specific, its usage in this
specification is actually referring to a general OAuth 2.0 feature
that is not specific to OpenID Connect.
r   z"op_tos_uri" MUST be a URLNrX   rY   s     r&   validate_op_tos_uri/AuthorizationServerMetadata.validate_op_tos_uri   s2     &e,,9:: -5r)   c                 l    U R                  S5      nU(       a  [        U5      (       d  [        S5      egg)zUOPTIONAL. URL of the authorization server's OAuth 2.0 revocation
endpoint [RFC7009].
r   z-"revocation_endpoint" MUST use "https" schemeNr8   r9   s     r&   validate_revocation_endpoint8AuthorizationServerMetadata.validate_revocation_endpoint   s4     hh,-*3//LMM 03r)   c                     [        U S5        g)a  OPTIONAL.  JSON array containing a list of client authentication
methods supported by this revocation endpoint.  The valid client
authentication method values are those registered in the IANA
"OAuth Token Endpoint Authentication Methods" registry
[IANA.OAuth.Parameters].  If omitted, the default is
"client_secret_basic" -- the HTTP Basic Authentication Scheme
specified in Section 2.3.1 of OAuth 2.0 [RFC6749].
r   Nr@   rB   s    r&   3validate_revocation_endpoint_auth_methods_supportedOAuthorizationServerMetadata.validate_revocation_endpoint_auth_methods_supported   s     	T#OPr)   c                 2    [        U SU R                  5        g)a  OPTIONAL.  JSON array containing a list of the JWS signing
algorithms ("alg" values) supported by the revocation endpoint for
the signature on the JWT [JWT] used to authenticate the client at
the revocation endpoint for the "private_key_jwt" and
"client_secret_jwt" authentication methods.  This metadata entry
MUST be present if either of these authentication methods are
specified in the "revocation_endpoint_auth_methods_supported"
entry.  No default algorithms are implied if this entry is
omitted.  The value "none" MUST NOT be used.
r   N)rT   r   rB   s    r&   >validate_revocation_endpoint_auth_signing_alg_values_supportedZAuthorizationServerMetadata.validate_revocation_endpoint_auth_signing_alg_values_supported   s     	C;;	
r)   c                 l    U R                  S5      nU(       a  [        U5      (       d  [        S5      egg)zYOPTIONAL.  URL of the authorization server's OAuth 2.0
introspection endpoint [RFC7662].
r   z0"introspection_endpoint" MUST use "https" schemeNr8   r9   s     r&   validate_introspection_endpoint;AuthorizationServerMetadata.validate_introspection_endpoint  s4     hh/0*3//OPP 03r)   c                     [        U S5        g)a  OPTIONAL.  JSON array containing a list of client authentication
methods supported by this introspection endpoint.  The valid
client authentication method values are those registered in the
IANA "OAuth Token Endpoint Authentication Methods" registry
[IANA.OAuth.Parameters] or those registered in the IANA "OAuth
Access Token Types" registry [IANA.OAuth.Parameters].  (These
values are and will remain distinct, due to Section 7.2.)  If
omitted, the set of supported authentication methods MUST be
determined by other means.
r   Nr@   rB   s    r&   6validate_introspection_endpoint_auth_methods_supportedRAuthorizationServerMetadata.validate_introspection_endpoint_auth_methods_supported  s     	T#RSr)   c                 2    [        U SU R                  5        g)a$  OPTIONAL.  JSON array containing a list of the JWS signing
algorithms ("alg" values) supported by the introspection endpoint
for the signature on the JWT [JWT] used to authenticate the client
at the introspection endpoint for the "private_key_jwt" and
"client_secret_jwt" authentication methods.  This metadata entry
MUST be present if either of these authentication methods are
specified in the "introspection_endpoint_auth_methods_supported"
entry.  No default algorithms are implied if this entry is
omitted.  The value "none" MUST NOT be used.
r   N)rT   r   rB   s    r&   Avalidate_introspection_endpoint_auth_signing_alg_values_supported]AuthorizationServerMetadata.validate_introspection_endpoint_auth_signing_alg_values_supported#  s     	F>>	
r)   c                     [        U S5        g)a  OPTIONAL.  JSON array containing a list of Proof Key for Code
Exchange (PKCE) [RFC7636] code challenge methods supported by this
authorization server.  Code challenge method values are used in
the "code_challenge_method" parameter defined in Section 4.3 of
[RFC7636].  The valid code challenge method values are those
registered in the IANA "PKCE Code Challenge Methods" registry
[IANA.OAuth.Parameters].  If omitted, the authorization server
does not support PKCE.
r   Nr@   rB   s    r&   )validate_code_challenge_methods_supportedEAuthorizationServerMetadata.validate_code_challenge_methods_supported4  s     	T#EFr)   c                 *    U R                  SSS/5      $ )Nr   r"   r#   r    rB   s    r&   r   4AuthorizationServerMetadata.response_modes_supported@  s     xx2Wj4IJJr)   c                 *    U R                  SSS/5      $ )Nr   r+   r,   r|   rB   s    r&   r   1AuthorizationServerMetadata.grant_types_supportedE  s     xx/2F
1STTr)   c                 (    U R                  SS/5      $ )Nr   client_secret_basicr|   rB   s    r&   r   AAuthorizationServerMetadata.token_endpoint_auth_methods_supportedJ  s     xx36K5L
 	
r)   c                 (    U R                  SS/5      $ )Nr   r   r|   rB   s    r&   r   FAuthorizationServerMetadata.revocation_endpoint_auth_methods_supportedQ  s     xx8;P:Q
 	
r)   c                 (    U R                  SS/5      $ )Nr   r   r|   rB   s    r&   r   IAuthorizationServerMetadata.introspection_endpoint_auth_methods_supportedX  s    
 xx;>S=T
 	
r)   c                 f    U R                    H!  n[        R                  U SU 35      " 5         M#     g)z#Validate all server metadata value.	validate_N)REGISTRY_KEYSobject__getattribute__)r$   keys     r&   validate$AuthorizationServerMetadata.validatea  s,    %%C##DIcU*;<> &r)   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)N)r   r   AttributeErrorr   r    )r$   r   errors      r&   __getattr__'AuthorizationServerMetadata.__getattr__f  sG    	**455 	(((xx}$K	s     
AA AAA N)%__name__
__module____qualname____firstlineno____doc__r   r'   r0   r5   r:   r=   rC   rH   rK   rN   rQ   rU   r[   r^   ra   rd   rg   rj   rm   rp   rs   rv   ry   propertyr   r   r   r   r   r   r   __static_attributes__r   r)   r&   r   r      s    M2B*E I&CP7N?<L
"
F;>;N	Q
"QT
"
G K K U U 
 
 
 
 
 
?
r)   r   c                    U R                  U5      nU(       a$  [        U[        5      (       d  [        SU S35      e[	        U5      nSS1nXE-  (       a  U(       d  [        SU S35      eU(       a  SU;   a  [        SU S35      eg g )N"" MUST be JSON arrayprivate_key_jwtclient_secret_jwtz" is requirednonez&the value "none" MUST NOT be used in ")r    rF   rG   r!   r-   )datar   auth_methods_supportedrZ   auth_methodsjwt_auth_methodss         r&   rT   rT   o  s    HHSMEZt,,1SE!5677-.L)+>?&q]3445A#aHII !ur)   c                 v    U R                  U5      nUb%  [        U[        5      (       d  [        SU S35      eg g )Nr   r   )r    rF   rG   r!   )metadatar   valuess      r&   rA   rA   ~  s?    \\#F*VT":":1SE!5677 #;r)   N)	authlib.common.securityr   authlib.common.urlsr   r   dictr   rT   rA   r   r)   r&   <module>r      s(    7 , (f$ fRJ8r)   