
    qh")                         S r SSKrSSKrSSKrSSKJrJr  SSKJr  SSK	J
r
Jr  SSKJr  SS	KJr  SS
KJr  \R$                  " \5      r " S S\
5      rg)z
oauthlib.oauth2.rfc6749.endpoint.metadata
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

An implementation of the `OAuth 2.0 Authorization Server Metadata`.

.. _`OAuth 2.0 Authorization Server Metadata`: https://tools.ietf.org/html/rfc8414
    N   )grant_typesutils   )AuthorizationEndpoint)BaseEndpointcatch_errors_and_unavailability)IntrospectEndpoint)RevocationEndpoint)TokenEndpointc                   f    \ rS rSrSr0 S4S jr\  SS j5       rSS jrS r	S	 r
S
 rS rS rSrg)MetadataEndpoint   a  OAuth2.0 Authorization Server Metadata endpoint.

This specification generalizes the metadata format defined by
`OpenID Connect Discovery 1.0` in a way that is compatible
with OpenID Connect Discovery while being applicable to a wider set
of OAuth 2.0 use cases.  This is intentionally parallel to the way
that OAuth 2.0 Dynamic Client Registration Protocol [`RFC7591`_]
generalized the dynamic client registration mechanisms defined by
OpenID Connect Dynamic Client Registration 1.0
in a way that is compatible with it.

.. _`OpenID Connect Discovery 1.0`: https://openid.net/specs/openid-connect-discovery-1_0.html
.. _`RFC7591`: https://tools.ietf.org/html/rfc7591
Tc                     [        U[        5      (       d   eU H  n[        U[        5      (       a  M   e   [        R                  " U 5        X0l        Xl        X l        U R                  5       U l        g )N)	
isinstancedictr   __init__raise_errors	endpointsinitial_claimsvalidate_metadata_serverclaims)selfr   r   r   endpoints        \/var/www/html/env/lib/python3.13/site-packages/oauthlib/oauth2/rfc6749/endpoints/metadata.pyr   MetadataEndpoint.__init__(   sc    &$''''!Hh5555 " 	d#("$335    Nc                 R    SSS.nU[         R                  " U R                  5      S4$ )z!Create metadata response
        zapplication/json*)zContent-TypezAccess-Control-Allow-Origin   )jsondumpsr   )r   urihttp_methodbodyheaderss        r   create_metadata_response)MetadataEndpoint.create_metadata_response3   s-     /+.
 

4;;/44r   c                    U R                   (       d  g X!;  a"  U(       a  [        SR                  U5      5      eg U(       ap  [        R                  " X   5      (       d  [        SR                  X!U   5      5      eSX   ;   d  SX   ;   d  SX   ;   a  [        SR                  X!U   5      5      eg U(       a6  X   R                  S5      (       d  [        SR                  X!U   5      5      eg U(       as  [        X   [        5      (       d  [        S	R                  X!U   5      5      eX    H6  n[        U[        5      (       a  M  [        S
R                  X!U   U5      5      e   g g )Nzkey {} is a mandatory metadata.zkey {}: {} must be an HTTPS URL?&#z8key {}: {} must not contain query or fragment componentshttpzkey {}: {} must be an URLzkey {}: {} must be an Arrayz/array {}: {} must contains only string (not {}))	r   
ValueErrorformatr   is_secure_transport
startswithr   liststr)r   arraykeyis_requiredis_listis_url	is_issuerelems           r   validate_metadata"MetadataEndpoint.validate_metadata>   sN      !B!I!I#!NOO  ,,UZ88 !B!I!I#UXz!Z[[ej C5:$5
9J ![!b!bcfnqhr!stt :K :((00 !<!C!CCs!TUU 1 ej$// !>!E!EcQT:!VWW
!$,,$%V%]%]^ailcmos%tuu # r   c                     U R                   R                  UR                   R                  5       5        UR                  SSS/5        U R	                  USSS9  U R	                  USSS9  U R	                  USSSS9  g	)
z
If the token endpoint is used in the grant type, the value of this
parameter MUST be the same as the value of the "grant_type"
parameter passed to the token endpoint defined in the grant type
definition.
%token_endpoint_auth_methods_supportedclient_secret_postclient_secret_basicTr7   0token_endpoint_auth_signing_alg_values_supportedtoken_endpointr6   r8   N)_grant_typesextendkeys
setdefaultr;   r   r   r   s      r   validate_metadata_token(MetadataEndpoint.validate_metadata_tokenW   s     	  !6!6!;!;!=>ADXZoCpqv'NX\]v'Ycghv'7TRVWr   c           
         UR                  S[        [        S UR                  R	                  5       5      5      5        UR                  SSS/5        SUS   ;   a  U R
                  R                  S5        U R                  USSSS	9  U R                  USSS
9  SUS   ;   a  UR                  S   n[        U[        R                  5      (       d  [        US5      (       a  UR                  nUR                  S[        UR                  R	                  5       5      5        U R                  USSS
9  U R                  USSSS9  g )Nresponse_types_supportedc                     U S:g  $ )Nnone )xs    r   <lambda>BMetadataEndpoint.validate_metadata_authorization.<locals>.<lambda>g   s    Vr   response_modes_supportedqueryfragmenttokenimplicitT)r6   r7   rA   codedefault_grant code_challenge_methods_supportedauthorization_endpointrD   )rH   r2   filter_response_typesrG   rE   appendr;   r   r   AuthorizationCodeGranthasattrrZ   _code_challenge_methods)r   r   r   
code_grants       r   validate_metadata_authorization0MetadataEndpoint.validate_metadata_authorizatione   s@   4v&;X=U=U=Z=Z=\]^	`4w
6KL
 f788$$Z0v'At]abv'A4PV677!11&9Jj+*L*LMMRYZdfuRvRv'55
@":#E#E#J#J#LMO""6+MW["\v'?TZ^_r   c                     UR                  SSS/5        U R                  USSS9  U R                  USSS9  U R                  USSSS9  g )	N*revocation_endpoint_auth_methods_supportedr?   r@   TrA   5revocation_endpoint_auth_signing_alg_values_supportedrevocation_endpointrD   rH   r;   rI   s      r   validate_metadata_revocation-MetadataEndpoint.validate_metadata_revocation|   sf    F/1FG	I 	v'S]abv'^hlmv'<$W[\r   c                     UR                  SSS/5        U R                  USSS9  U R                  USSS9  U R                  USSSS9  g )	N-introspection_endpoint_auth_methods_supportedr?   r@   TrA   8introspection_endpoint_auth_signing_alg_values_supportedintrospection_endpointrD   rj   rI   s      r   validate_metadata_introspection0MetadataEndpoint.validate_metadata_introspection   sf    I/1FG	I 	v'V`dev'akopv'?TZ^_r   c                    [         R                  " U R                  5      nU R                  USSSS9  U R                  USSS9  U R                  USSS9  U R                  USSS9  U R                  US	SS9  U R                  US
SS9  U R                  USSS9  / U l        U R
                   H  n[        U[        5      (       a  U R                  X5        [        U[        5      (       a  U R                  X5        [        U[        5      (       a  U R                  X5        [        U[        5      (       d  M  U R                  X5        M     UR                  SU R                  5        U R                  USSS9  U$ )aN  
 Authorization servers can have metadata describing their
 configuration.  The following authorization server metadata values
 are used by this specification. More details can be found in
 `RFC8414 section 2`_ :

issuer
   REQUIRED

authorization_endpoint
   URL of the authorization server's authorization endpoint
   [`RFC6749#Authorization`_].  This is REQUIRED unless no grant types are supported
   that use the authorization endpoint.

token_endpoint
   URL of the authorization server's token endpoint [`RFC6749#Token`_].  This
   is REQUIRED unless only the implicit grant type is supported.

scopes_supported
   RECOMMENDED.

response_types_supported
   REQUIRED.

Other OPTIONAL fields:
   jwks_uri,
   registration_endpoint,
   response_modes_supported

grant_types_supported
   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"]".

token_endpoint_auth_methods_supported

token_endpoint_auth_signing_alg_values_supported

service_documentation

ui_locales_supported

op_policy_uri

op_tos_uri

revocation_endpoint

revocation_endpoint_auth_methods_supported

revocation_endpoint_auth_signing_alg_values_supported

introspection_endpoint

introspection_endpoint_auth_methods_supported

introspection_endpoint_auth_signing_alg_values_supported

code_challenge_methods_supported

Additional authorization server metadata parameters MAY also be used.
Some are defined by other specifications, such as OpenID Connect
Discovery 1.0 [`OpenID.Discovery`_].

 .. _`RFC8414 section 2`: https://tools.ietf.org/html/rfc8414#section-2
 .. _`RFC6749#Authorization`: https://tools.ietf.org/html/rfc6749#section-3.1
 .. _`RFC6749#Token`: https://tools.ietf.org/html/rfc6749#section-3.2
 .. _`RFC7591`: https://tools.ietf.org/html/rfc7591
 .. _`OpenID.Discovery`: https://openid.net/specs/openid-connect-discovery-1_0.html
 issuerT)r6   r9   jwks_uri)r8   scopes_supportedrA   service_documentationui_locales_supportedop_policy_uri
op_tos_urigrant_types_supported)copydeepcopyr   r;   rE   r   r   r   rJ   r   rd   r   rk   r
   rq   rH   rI   s      r   r   )MetadataEndpoint.validate_metadata_server   sj   T t223vxTTRvz$?v'94Hv'>tLv'=tLvtDv|DAH(M22,,V>($9::44VF($67711&C($67744VF ' 	143D3DEv'>Mr   )rE   r   r   r   r   )GETNN)FFFF)__name__
__module____qualname____firstlineno____doc__r   r	   r'   r;   rJ   rd   rk   rq   r   __static_attributes__rP   r   r   r   r      sQ     *,$ 	6 %DH)-5 %5v2X`.]`br   r   )r   r|   r!   logging r   r   authorizationr   baser   r	   
introspectr
   
revocationr   rW   r   	getLoggerr   logr   rP   r   r   <module>r      sE       ! 0 ? * *  !W| Wr   