o
    Df1                     @   s4   d dl mZ d dlmZ G dd deZdd ZdS )    )AuthorizationServerMetadatavalidate_array_valuec                       s   e Zd Zg dZ fddZdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! Zd"d# Zd$d% Zd&d' Zd(d) Zed*d+ Zed,d- Zed.d/ Zed0d1 Zed2d3 Z  ZS )4OpenIDProviderMetadata)"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acr_values_supportedsubject_types_supported%id_token_signing_alg_values_supported(id_token_encryption_alg_values_supported(id_token_encryption_enc_values_supported%userinfo_signing_alg_values_supported(userinfo_encryption_alg_values_supported(userinfo_encryption_enc_values_supported+request_object_signing_alg_values_supported.request_object_encryption_alg_values_supported.request_object_encryption_enc_values_supporteddisplay_values_supportedclaim_types_supportedclaims_supportedclaims_locales_supportedclaims_parameter_supportedrequest_parameter_supportedrequest_uri_parameter_supported require_request_uri_registrationc                    s$   |  d}|d u rtdt  S )Nr	   z"jwks_uri" is required)get
ValueErrorsupervalidate_jwks_uri)selfr	   	__class__ V/home/ubuntu/webapp/venv/lib/python3.10/site-packages/authlib/oidc/discovery/models.pyr+   .   s   

z(OpenIDProviderMetadata.validate_jwks_uric                 C      t | d dS )z}OPTIONAL. JSON array containing a list of the Authentication
        Context Class References that this OP supports.
        r   Nr   r,   r/   r/   r0   validate_acr_values_supported5   s   z4OpenIDProviderMetadata.validate_acr_values_supportedc                 C   sN   |  d}|du rtdt|tstdddh}|t|s%tddS )zREQUIRED. JSON array containing a list of the Subject Identifier
        types that this OP supports. Valid types include pairwise and public.
        r   Nz%"subject_types_supported" is requiredz,"subject_types_supported" MUST be JSON arraypairwisepublicz1"subject_types_supported" contains invalid values)r(   r)   
isinstancelist
issupersetset)r,   valuesvalid_typesr/   r/   r0    validate_subject_types_supported;   s   

z7OpenIDProviderMetadata.validate_subject_types_supportedc                 C   s@   |  d}|du rtdt|tstdd|vrtddS )a  REQUIRED. JSON array containing a list of the JWS signing
        algorithms (alg values) supported by the OP for the ID Token to
        encode the Claims in a JWT [JWT]. The algorithm RS256 MUST be
        included. The value none MAY be supported, but MUST NOT be used
        unless the Response Type used returns no ID Token from the
        Authorization Endpoint (such as when using the Authorization
        Code Flow).
        r   Nz3"id_token_signing_alg_values_supported" is requiredz:"id_token_signing_alg_values_supported" MUST be JSON arrayRS256zC"RS256" MUST be included in "id_token_signing_alg_values_supported")r(   r)   r6   r7   r,   r:   r/   r/   r0   .validate_id_token_signing_alg_values_supportedN   s   


zEOpenIDProviderMetadata.validate_id_token_signing_alg_values_supportedc                 C   r1   )zOPTIONAL. JSON array containing a list of the JWE encryption
        algorithms (alg values) supported by the OP for the ID Token to
        encode the Claims in a JWT.
        r   Nr   r2   r/   r/   r0   1validate_id_token_encryption_alg_values_supportede      zHOpenIDProviderMetadata.validate_id_token_encryption_alg_values_supportedc                 C   r1   )zOPTIONAL. JSON array containing a list of the JWE encryption
        algorithms (enc values) supported by the OP for the ID Token to
        encode the Claims in a JWT.
        r   Nr   r2   r/   r/   r0   1validate_id_token_encryption_enc_values_supportedl   rA   zHOpenIDProviderMetadata.validate_id_token_encryption_enc_values_supportedc                 C   r1   )zOPTIONAL. JSON array containing a list of the JWS signing
        algorithms (alg values) [JWA] supported by the UserInfo Endpoint
        to encode the Claims in a JWT. The value none MAY be included.
        r   Nr   r2   r/   r/   r0   .validate_userinfo_signing_alg_values_supporteds   rA   zEOpenIDProviderMetadata.validate_userinfo_signing_alg_values_supportedc                 C   r1   )zOPTIONAL. JSON array containing a list of the JWE encryption
        algorithms (alg values) [JWA] supported by the UserInfo Endpoint
        to encode the Claims in a JWT.
        r   Nr   r2   r/   r/   r0   1validate_userinfo_encryption_alg_values_supportedz   rA   zHOpenIDProviderMetadata.validate_userinfo_encryption_alg_values_supportedc                 C   r1   )zOPTIONAL. JSON array containing a list of the JWE encryption
        algorithms (enc values) [JWA] supported by the UserInfo Endpoint
        to encode the Claims in a JWT.
        r   Nr   r2   r/   r/   r0   1validate_userinfo_encryption_enc_values_supported   rA   zHOpenIDProviderMetadata.validate_userinfo_encryption_enc_values_supportedc                 C   s@   |  d}|s	dS t|tstdd|vsd|vrtddS )a  OPTIONAL. JSON array containing a list of the JWS signing
        algorithms (alg values) supported by the OP for Request Objects,
        which are described in Section 6.1 of OpenID Connect Core 1.0.
        These algorithms are used both when the Request Object is passed
        by value (using the request parameter) and when it is passed by
        reference (using the request_uri parameter). Servers SHOULD support
        none and RS256.
        r   Nz@"request_object_signing_alg_values_supported" MUST be JSON arraynoner=   zK"request_object_signing_alg_values_supported" SHOULD support none and RS256)r(   r6   r7   r)   r>   r/   r/   r0   4validate_request_object_signing_alg_values_supported   s   
	
zKOpenIDProviderMetadata.validate_request_object_signing_alg_values_supportedc                 C   r1   )a  OPTIONAL. JSON array containing a list of the JWE encryption
        algorithms (alg values) supported by the OP for Request Objects.
        These algorithms are used both when the Request Object is passed
        by value and when it is passed by reference.
        r   Nr   r2   r/   r/   r0   7validate_request_object_encryption_alg_values_supported      zNOpenIDProviderMetadata.validate_request_object_encryption_alg_values_supportedc                 C   r1   )a  OPTIONAL. JSON array containing a list of the JWE encryption
        algorithms (enc values) supported by the OP for Request Objects.
        These algorithms are used both when the Request Object is passed
        by value and when it is passed by reference.
        r   Nr   r2   r/   r/   r0   7validate_request_object_encryption_enc_values_supported   rI   zNOpenIDProviderMetadata.validate_request_object_encryption_enc_values_supportedc                 C   F   |  d}|s	dS t|tstdh d}|t|s!tddS )zOPTIONAL. JSON array containing a list of the display parameter
        values that the OpenID Provider supports. These values are described
        in Section 3.1.2.1 of OpenID Connect Core 1.0.
        r    Nz-"display_values_supported" MUST be JSON array>   wappagepopuptouchz2"display_values_supported" contains invalid valuesr(   r6   r7   r)   r8   r9   r,   r:   valid_valuesr/   r/   r0   !validate_display_values_supported   s   

z8OpenIDProviderMetadata.validate_display_values_supportedc                 C   rK   )aZ  OPTIONAL. JSON array containing a list of the Claim Types that
        the OpenID Provider supports. These Claim Types are described in
        Section 5.6 of OpenID Connect Core 1.0. Values defined by this
        specification are normal, aggregated, and distributed. If omitted,
        the implementation supports only normal Claims.
        r!   Nz*"claim_types_supported" MUST be JSON array>   normal
aggregateddistributedz/"claim_types_supported" contains invalid valuesrP   rQ   r/   r/   r0   validate_claim_types_supported   s   

z5OpenIDProviderMetadata.validate_claim_types_supportedc                 C   r1   )zRECOMMENDED. JSON array containing a list of the Claim Names
        of the Claims that the OpenID Provider MAY be able to supply values
        for. Note that for privacy or other reasons, this might not be an
        exhaustive list.
        r"   Nr   r2   r/   r/   r0   validate_claims_supported   rI   z0OpenIDProviderMetadata.validate_claims_supportedc                 C   r1   )a  OPTIONAL. Languages and scripts supported for values in Claims
        being returned, represented as a JSON array of BCP47 [RFC5646]
        language tag values. Not all languages and scripts are necessarily
        supported for all Claim values.
        r#   Nr   r2   r/   r/   r0   !validate_claims_locales_supported   rI   z8OpenIDProviderMetadata.validate_claims_locales_supportedc                 C   r1   )zOPTIONAL. Boolean value specifying whether the OP supports use of
        the claims parameter, with true indicating support. If omitted, the
        default value is false.
        r$   N_validate_boolean_valuer2   r/   r/   r0   #validate_claims_parameter_supported   rA   z:OpenIDProviderMetadata.validate_claims_parameter_supportedc                 C   r1   )zOPTIONAL. Boolean value specifying whether the OP supports use of
        the request parameter, with true indicating support. If omitted, the
        default value is false.
        r%   NrZ   r2   r/   r/   r0   $validate_request_parameter_supported   rA   z;OpenIDProviderMetadata.validate_request_parameter_supportedc                 C   r1   )zOPTIONAL. Boolean value specifying whether the OP supports use of
        the request_uri parameter, with true indicating support. If omitted,
        the default value is true.
        r&   NrZ   r2   r/   r/   r0   (validate_request_uri_parameter_supported   rA   z?OpenIDProviderMetadata.validate_request_uri_parameter_supportedc                 C   r1   )a  OPTIONAL. Boolean value specifying whether the OP requires any
        request_uri values used to be pre-registered using the request_uris
        registration parameter. Pre-registration is REQUIRED when the value
        is true. If omitted, the default value is false.
        r'   NrZ   r2   r/   r/   r0   )validate_require_request_uri_registration   rI   z@OpenIDProviderMetadata.validate_require_request_uri_registrationc                 C   s   |  ddgS )Nr!   rT   r(   r2   r/   r/   r0   r!      s   z,OpenIDProviderMetadata.claim_types_supportedc                 C      |  ddS )Nr$   Fr`   r2   r/   r/   r0   r$        z1OpenIDProviderMetadata.claims_parameter_supportedc                 C   ra   )Nr%   Fr`   r2   r/   r/   r0   r%     rb   z2OpenIDProviderMetadata.request_parameter_supportedc                 C   ra   )Nr&   Tr`   r2   r/   r/   r0   r&     rb   z6OpenIDProviderMetadata.request_uri_parameter_supportedc                 C   ra   )Nr'   Fr`   r2   r/   r/   r0   r'     rb   z7OpenIDProviderMetadata.require_request_uri_registration)__name__
__module____qualname__REGISTRY_KEYSr+   r3   r<   r?   r@   rB   rC   rD   rE   rG   rH   rJ   rS   rW   rX   rY   r\   r]   r^   r_   propertyr!   r$   r%   r&   r'   __classcell__r/   r/   r-   r0   r      s@    (



r   c                 C   s,   || vrd S | | dvrt d| dd S )N)TF"z" MUST be boolean)r)   )metadatakeyr/   r/   r0   r[     s
   r[   N)authlib.oauth2.rfc8414r   authlib.oauth2.rfc8414.modelsr   r   r[   r/   r/   r/   r0   <module>   s      