o
    ÿÑÐbÇ  ã                   @   s(   d Z ddlmZmZ G dd„ deƒZdS )zè
    authlib.oauth2.rfc6749.resource_protector
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Implementation of Accessing Protected Resources per `Section 7`_.

    .. _`Section 7`: https://tools.ietf.org/html/rfc6749#section-7
é   )ÚMissingAuthorizationErrorÚUnsupportedTokenTypeErrorc                   @   s&   e Zd Zdd„ Zdd„ Zd	dd„ZdS )
ÚResourceProtectorc                 C   s
   i | _ d S ©N)Ú_token_validators)Úself© r   úh/var/www/secure340b-portal/env/lib/python3.10/site-packages/authlib/oauth2/rfc6749/resource_protector.pyÚ__init__   s   
zResourceProtector.__init__c                 C   s    |j | jvr|| j|j < d S d S r   )Z
TOKEN_TYPEr   )r   Ú	validatorr   r   r	   Úregister_token_validator   s   ÿz*ResourceProtector.register_token_validatorÚANDc           	      C   sd   |j  d¡}|stƒ ‚| d d¡}t|ƒdkrtƒ ‚|\}}| j | ¡ ¡}|s+tƒ ‚|||||ƒS )NÚAuthorizationr   é   )ÚheadersÚgetr   ÚsplitÚlenr   r   Úlower)	r   ÚscopeÚrequestZscope_operatorÚauthZtoken_partsÚ
token_typeZtoken_stringr   r   r   r	   Úvalidate_request   s   z"ResourceProtector.validate_requestN)r   )Ú__name__Ú
__module__Ú__qualname__r
   r   r   r   r   r   r	   r      s    r   N)Ú__doc__Úerrorsr   r   Úobjectr   r   r   r   r	   Ú<module>   s    	