
    ci                     B    d Z ddlmZ ddlmZ ddlmZ  G d de      Zy)	z{authlib.oauth2.rfc6750.validator.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Validate Bearer Token for in request, scope and token.
   )TokenValidator   )InsufficientScopeError)InvalidTokenErrorc                       e Zd ZdZd Zd Zy)BearerTokenValidatorbearerc                     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_strings     G/tmp/pip-target-z3e9_cxr/lib/python/authlib/oauth2/rfc6750/validator.pyauthenticate_tokenz'BearerTokenValidator.authenticate_token   s     "##    c                 b   |s!t        | j                  | j                        |j                         r!t        | j                  | j                        |j	                         r!t        | j                  | j                        | j                  |j                         |      r
t               y)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requests       r   validate_tokenz#BearerTokenValidator.validate_token   s    #jj43H3H  #jj43H3H  #jj43H3H  ""5??#4f=(** >r   N)__name__
__module____qualname__
TOKEN_TYPEr   r    r   r   r   r      s    J
$+r   r   N)__doc__rfc6749r   errorsr   r   r   r    r   r   <module>r$      s!    % * %+> +r   