�
�c") � � � d Z ddlZddlZddlZddlmZmZ ddlmZ ddl m
Z
mZ ddlm
Z
dd lmZ dd
lmZ ej$ e� Z G d� de
� Zy)
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 �X � e Zd ZdZi dfd�Ze dd�� Zd
d�Zd� Zd� Z d � Z
d
� Zd� Zy)�MetadataEndpointa� 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 �� � t |t � sJ �|D ] }t |t � r�J � t j | � || _ || _ || _ | j � | _ y )N) �
isinstance�dictr �__init__�raise_errors� endpoints�initial_claims�validate_metadata_server�claims)�selfr r r �endpoints �L/usr/lib/python3/dist-packages/oauthlib/oauth2/rfc6749/endpoints/metadata.pyr zMetadataEndpoint.__init__( sh � ��&�$�'�'�'�!� 6�H��h��5�5�5� 6� ���d�#�(���"���$����3�3�5��� Nc �P � ddd�}|t j | j � dfS )z!Create metadata response
zapplication/json�*)zContent-TypezAccess-Control-Allow-Origin�� )�json�dumpsr )r �uri�http_method�body�headerss r �create_metadata_responsez)MetadataEndpoint.create_metadata_response3 s- � � /�+.�
�� ��
�
�4�;�;�/��4�4r c �| � | j sy ||vr|rt dj |� � �y |rjt j || � st dj ||| � � �d|| v sd|| v sd|| v rt dj ||| � � �y |r3|| j d� st dj ||| � � �y |rkt
|| t � st d j ||| � � �|| D ]1 }t
|t � r�t d
j ||| |� � � y y )Nzkey {} is a mandatory metadata.zkey {}: {} must be an HTTPS URL�?�&�#z8key {}: {} must not contain query or fragment components�httpzkey {}: {} must be an URLzkey {}: {} 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_metadataz"MetadataEndpoint.validate_metadata> |