o
    _J@h                     @   sd   d Z ddlZddlmZ ddlmZmZ dd ZG dd	 d	eZ	G d
d de
ZG dd deZdS )z$Provides classes for authentication.    N)request   )bytes_to_wsgiwsgi_to_bytesc                  C   sT   t jd} | s
dS t| } z| dd\}}| }W ||fS  ty)   Y dS w )zV
    Return request's 'Authorization:' header as
    a two-tuple of (type, info).
    ZHTTP_AUTHORIZATIONNr   )r   environgetr   splitlower
ValueError)header	auth_type	auth_info r   I/var/www/html/venv/lib/python3.10/site-packages/flask_apscheduler/auth.pyget_authorization_header   s   
r   c                       s    e Zd ZdZ fddZ  ZS )Authorizationzx
    A class to hold the authorization data.

    :param str auth_type: The authorization type. e.g: basic, bearer.
    c                    s    t t| jdi | || _d S )Nr   )superr   __init__r   )selfr   kwargs	__class__r   r   r   2   s   
zAuthorization.__init__)__name__
__module____qualname____doc__r   __classcell__r   r   r   r   r   ,   s    r   c                   @   s    e Zd ZdZdd Zdd ZdS )HTTPAuthzL
    A base class from which all authentication classes should inherit.
    c                 C   s   t  )z
        Get the authorization header.
        :return Authentication: The authentication data or None if it is not present or invalid.
        )NotImplementedr   r   r   r   get_authorization=   s   zHTTPAuth.get_authorizationc                 C   s   dS )l
        Return the value of `WWW-Authenticate` header in a
        `401 Unauthenticated` response.
        Nr   r   r   r   r   get_authenticate_headerD   s   z HTTPAuth.get_authenticate_headerN)r   r   r   r   r    r"   r   r   r   r   r   8   s    r   c                   @   s$   e Zd ZdZdZdd Zdd ZdS )HTTPBasicAuthz$
    HTTP Basic authentication.
    zAuthentication Requiredc                 C   sh   t  }|sdS |\}}|dkrdS zt|dd\}}W n
 ty(   Y dS w tdt|t|dS )z
        Get the username and password for Basic authentication header.
        :return Authentication: The authentication data or None if it is not present or invalid.
        Ns   basic   :r   basic)usernamepassword)r   base64	b64decoder   	Exceptionr   r   )r   authr   r   r&   r'   r   r   r   r    R   s   zHTTPBasicAuth.get_authorizationc                 C   s   d| j  dS )r!   zBasic realm="")www_authenticate_realmr   r   r   r   r"   h   s   z%HTTPBasicAuth.get_authenticate_headerN)r   r   r   r   r-   r    r"   r   r   r   r   r#   L   s
    r#   )r   r(   Zflaskr   utilsr   r   r   dictr   objectr   r#   r   r   r   r   <module>   s   