o
    Dfa                     @   s4   d Z ddlmZ ddlmZmZ G dd deZdS )z
    authlib.oauth2.rfc6750.validator
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Validate Bearer Token for in request, scope and token.
   )TokenValidator   )InvalidTokenErrorInsufficientScopeErrorc                   @   s    e Zd ZdZdd Zdd ZdS )BearerTokenValidatorbearerc                 C   s   t  )a_  A method to query token from database with the given token string.
        Developers MUST re-implement this method. For instance::

            def authenticate_token(self, token_string):
                return get_token_from_database(token_string)

        :param token_string: A string to represent the access_token.
        :return: token
        )NotImplementedError)selftoken_string r   Y/home/ubuntu/webapp/venv/lib/python3.10/site-packages/authlib/oauth2/rfc6750/validator.pyauthenticate_token   s   
z'BearerTokenValidator.authenticate_tokenc                 C   s^   |s
t | j| jd| rt | j| jd| r"t | j| jd| | |r-t dS )z:Check if token is active and matches the requested scopes.)realmextra_attributesN)r   r   r   
is_expired
is_revokedscope_insufficient	get_scoper   )r	   tokenscopesrequestr   r   r   validate_token   s   z#BearerTokenValidator.validate_tokenN)__name__
__module____qualname__
TOKEN_TYPEr   r   r   r   r   r   r      s    r   N)__doc__rfc6749r   errorsr   r   r   r   r   r   r   <module>   s    