�
�c") � � � d Z ddlZddlZddlZddlmZmZ ddlmZ ddl m
Z
mZ ddlm
Z
dd lmZ dd
lmZ ej e� � Z G d� de
� � ZdS )
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 �` � e Zd ZdZi dfd�Ze dd�� � Zdd�Zd � Zd
� Z d� Z
d� Zd
� ZdS )�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 � � sJ ��t j | � � || _ || _ || _ | � � � | _ d S )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__( s � ��&�$�'�'�'�'�'�!� 6� 6�H��h��5�5�5�5�5�5���d�#�#�#�(���"���$����3�3�5�5����� �GETNc �D � 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 s1 � � /�+.�
�
�� ��
�4�;�/�/��4�4r Fc �< � | j sd S ||vr&|r"t d� |� � � � �d S |r�t j || � � s)t d� ||| � � � � �d|| v sd|| v s
d|| v r)t d� ||| � � � � �d S |rF|| � d� � s)t d� ||| � � � � �d S |r�t
|| t � � s)t d � ||| � � � � �|| D ]C}t
|t � � s*t d
� ||| |� � � � ��Bd S d S )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> |