
    &g                     v    d Z ddlZddlmZ ddlmZ ddlmZmZ  ej	        e
          Z G d de          ZdS )	z
oauthlib.oauth2.rfc6749
~~~~~~~~~~~~~~~~~~~~~~~

This module is an implementation of various logic needed
for consuming and providing OAuth 2.0 RFC6749.
    N)Request)utils   )BaseEndpointcatch_errors_and_unavailabilityc                       e Zd ZdZd Zed             Zed             Zed             Zed             Z	e
	 	 dd	            Ze
	 	 dd
            ZdS )AuthorizationEndpointaa  Authorization endpoint - used by the client to obtain authorization
    from the resource owner via user-agent redirection.

    The authorization endpoint is used to interact with the resource
    owner and obtain an authorization grant.  The authorization server
    MUST first verify the identity of the resource owner.  The way in
    which the authorization server authenticates the resource owner (e.g.
    username and password login, session cookies) is beyond the scope of
    this specification.

    The endpoint URI MAY include an "application/x-www-form-urlencoded"
    formatted (per `Appendix B`_) query component,
    which MUST be retained when adding additional query parameters.  The
    endpoint URI MUST NOT include a fragment component::

        https://example.com/path?query=component             # OK
        https://example.com/path?query=component#fragment    # Not OK

    Since requests to the authorization endpoint result in user
    authentication and the transmission of clear-text credentials (in the
    HTTP response), the authorization server MUST require the use of TLS
    as described in Section 1.6 when sending requests to the
    authorization endpoint::

        # We will deny any request which URI schema is not with https

    The authorization server MUST support the use of the HTTP "GET"
    method [RFC2616] for the authorization endpoint, and MAY support the
    use of the "POST" method as well::

        # HTTP method is currently not enforced

    Parameters sent without a value MUST be treated as if they were
    omitted from the request.  The authorization server MUST ignore
    unrecognized request parameters.  Request and response parameters
    MUST NOT be included more than once::

        # Enforced through the design of oauthlib.common.Request

    .. _`Appendix B`: https://tools.ietf.org/html/rfc6749#appendix-B
    c                 X    t          j        |            || _        || _        || _        d S N)r   __init___response_types_default_response_type_default_token_type)selfdefault_response_typedefault_token_typeresponse_typess       a/var/www/api/venv/lib/python3.11/site-packages/oauthlib/oauth2/rfc6749/endpoints/authorization.pyr   zAuthorizationEndpoint.__init__>   s1    d###-&;##5       c                     | j         S r   )r   r   s    r   r   z$AuthorizationEndpoint.response_typesE   s    ##r   c                     | j         S r   )r   r   s    r   r   z+AuthorizationEndpoint.default_response_typeI   s    **r   c                 @    | j                             | j                  S r   )r   getr   r   s    r   default_response_type_handlerz3AuthorizationEndpoint.default_response_type_handlerM   s    "&&t'ABBBr   c                     | j         S r   )r   r   s    r   r   z(AuthorizationEndpoint.default_token_typeQ   s    ''r   GETNc                 `   t          ||||          }||_        d|_        |pi                                 D ]\  }}	t	          |||	           | j                            |j        | j                  }
t          
                    d|j        |
           |
                    || j                  S ):Extract response_type and route to the designated handler.http_methodbodyheadersNz+Dispatching response_type %s request to %r.)r   scopesuseritemssetattrr   r   response_typer   logdebugcreate_authorization_responser   )r   urir!   r"   r#   r$   credentialsrequestkvresponse_type_handlers              r   r+   z3AuthorizationEndpoint.create_authorization_responseU   s     [tWF F F &B--// 	# 	#DAqGQ"""" $ 3 7 7!4#E!G !G		?')>	@ 	@ 	@$BBT,. . 	.r   c                     t          ||||          }t          j        |j                  |_        | j                            |j        | j                  }|	                    |          S )r   r    )
r   r   scope_to_listscoper$   r   r   r(   r   validate_authorization_request)r   r,   r!   r"   r#   r.   r1   s          r   r5   z4AuthorizationEndpoint.validate_authorization_requestg   st     [tWF F F ,W];; $ 3 7 7!4#E!G !G$CCGLLLr   )r   NNNN)r   NN)__name__
__module____qualname____doc__r   propertyr   r   r   r   r   r+   r5    r   r   r	   r	      s        ( (T6 6 6 $ $ X$ + + X+ C C XC ( ( X( %IMMQ. . . %$." %JN/3
M 
M 
M %$
M 
M 
Mr   r	   )r9   loggingoauthlib.commonr   oauthlib.oauth2.rfc6749r   baser   r   	getLoggerr6   r)   r	   r;   r   r   <module>rA      s      # # # # # # ) ) ) ) ) ) ? ? ? ? ? ? ? ?g!!`M `M `M `M `ML `M `M `M `M `Mr   