a
    ¶ã1bR	  ã                   @   s@   d dl mZ G dd„ deƒZG dd„ deƒZG dd„ deƒZdS )	é   )ÚDictSerialiseMixinc                   @   s   e Zd ZdS )ÚAuthenticationFailureN)Ú__name__Ú
__module__Ú__qualname__© r   r   ú/lib/python3.9/site-packages/intake/auth/base.pyr      s   r   c                   @   s2   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	d
„ZdS )ÚBaseAuthz—Base class for authorization

    Subclass this and override the methods to implement a new type of auth.

    This basic class allows all access.
    c                 G   s
   || _ d S ©N©Úargs©Úselfr   r   r   r   Ú__init__   s    zBaseAuth.__init__c                 C   s   dS )zµIs the requests header given allowed to talk to the server

        Parameters
        ----------
        header: dict
            The HTTP header from the incoming request
        Tr   )r   Úheaderr   r   r   Úallow_connect   s    zBaseAuth.allow_connectc                 C   s   dS )a_  Is the given HTTP header allowed to access given data source

        Parameters
        ----------
        header: dict
            The HTTP header from the incoming request
        source: CatalogEntry
            The data source the user wants to access.
        catalog: Catalog
            The catalog object containing this data source.
        Tr   )r   r   ÚsourceÚcatalogr   r   r   Úallow_access$   s    zBaseAuth.allow_accessNc                 C   s2   |  ¡ }| ¡ D ]\}}||  ¡ kr|  S q|S )z~Case-insensitive search of a dictionary for key.

        Returns the value if key match is found, otherwise default.
        N)ÚlowerÚitems)r   Z
dictionaryÚkeyÚdefaultZ	lower_keyÚkÚvr   r   r   Úget_case_insensitive2   s
    
zBaseAuth.get_case_insensitive)N)r   r   r   Ú__doc__r   r   r   r   r   r   r   r   r	      s
   
r	   c                   @   s<   e Zd ZdZdd„ Zdd„ Zedd„ ƒZdd	„ Zd
d„ Z	dS )ÚBaseClientAuthz€Base class for client-side setting of authorization headers

    This basic class adds no headers to remote catalog reqests
    c                 G   s
   || _ d S r
   r   r   r   r   r   r   E   s    zBaseClientAuth.__init__c                 C   s   t | ƒS r
   )Úhash©r   r   r   r   Ú__dask_tokenize__H   s    z BaseClientAuth.__dask_tokenize__c                 C   s"   ddl m} |t| ƒj| jdœƒS )Né    )Útokenize)Úclsr   )Z	dask.baser"   Útyper   r   )r   r"   r   r   r   Ú_tokK   s    zBaseClientAuth._tokc                 C   s   t | jdƒS )Né   )Úintr%   r   r   r   r   Ú__hash__P   s    zBaseClientAuth.__hash__c                 C   s   i S )zMReturns a dictionary of HTTP headers for the remote catalog request.
        r   r   r   r   r   Úget_headersS   s    zBaseClientAuth.get_headersN)
r   r   r   r   r   r    Úpropertyr%   r(   r)   r   r   r   r   r   ?   s   
r   N)Zutilsr   Ú	Exceptionr   r	   Úobjectr   r   r   r   r   Ú<module>   s   0