o
    ¹3ÇO�  ã                   @   s:   d Z eZddgZddlZG dd„ dƒZG dd„ deƒZdS )a	  Classes to authorize lazr.restfulclient with various web services.

This module includes an authorizer classes for HTTP Basic Auth,
as well as a base-class authorizer that does nothing.

A set of classes for authorizing with OAuth is located in the 'oauth'
module.
ÚBasicHttpAuthorizerÚHttpAuthorizeré    Nc                   @   s,   e Zd ZdZdd„ Zdd„ Zedd„ ƒZdS )	r   aÇ  Handles authentication for HTTP requests.

    There are two ways to authenticate.

    The authorize_session() method is called once when the client is
    initialized. This works for authentication methods like Basic
    Auth.  The authorize_request is called for every HTTP request,
    which is useful for authentication methods like Digest and OAuth.

    The base class is a null authorizer which does not perform any
    authentication at all.
    c                 C   ó   dS )z*Set up credentials for the entire session.N© ©ÚselfÚclientr   r   úG/usr/lib/python3/dist-packages/lazr/restfulclient/authorize/__init__.pyÚauthorizeSession2   s   zHttpAuthorizer.authorizeSessionc                 C   r   )ztSet up credentials for a single request.

        This probably involves setting the Authentication header.
        Nr   ©r   Úabsolute_uriÚmethodÚbodyÚheadersr   r   r	   ÚauthorizeRequest6   s   zHttpAuthorizer.authorizeRequestc                 C   s   i S )aG  Any parameters necessary to identify this user agent.

        By default this is an empty dict (because authentication
        details don't contain any information about the application
        making the request), but when a resource is protected by
        OAuth, the OAuth consumer name is part of the user agent.
        r   )r   r   r   r	   Úuser_agent_params=   s   	z HttpAuthorizer.user_agent_paramsN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r
   r   Úpropertyr   r   r   r   r	   r   %   s    c                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	r   z=Handles authentication for services that use HTTP Basic Auth.c                 C   s   || _ || _dS )z¬Constructor.

        :param username: User to send as authorization for all requests.
        :param password: Password to send as authorization for all requests.
        N)ÚusernameÚpassword)r   r   r   r   r   r	   Ú__init__L   s   
zBasicHttpAuthorizer.__init__c                 C   s&   dt  d| j| jf ¡ ¡  |d< dS )zySet up credentials for a single request.

        This sets the authorization header with the username/password.
        zBasic z%s:%sÚauthorizationN)Úbase64Ú	b64encoder   r   Ústripr   r   r   r	   r   U   s
   ÿÿz$BasicHttpAuthorizer.authorizeRequestc                 C   s   |  | j| j¡ d S )N)Úadd_credentialsr   r   r   r   r   r	   r
   ]   s   z$BasicHttpAuthorizer.authorizeSessionN)r   r   r   r   r   r   r
   r   r   r   r	   r   I   s
    	)r   ÚtypeÚ__metaclass__Ú__all__r   r   r   r   r   r   r	   Ú<module>   s   	þ$