
    };e                     F    d Z eZddgZddlZ G d d      Z G d de      Zy)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                   ,    e Zd ZdZd Zd Zed        Zy)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                      y)z*Set up credentials for the entire session.N selfclients     G/usr/lib/python3/dist-packages/lazr/restfulclient/authorize/__init__.pyauthorizeSessionzHttpAuthorizer.authorizeSession3   s        c                      y)ztSet up credentials for a single request.

        This probably involves setting the Authentication header.
        Nr   r	   absolute_urimethodbodyheaderss        r   authorizeRequestzHttpAuthorizer.authorizeRequest7   s    
 	r   c                     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	   s    r   user_agent_paramsz HttpAuthorizer.user_agent_params>   s	     	r   N)__name__
__module____qualname____doc__r   r   propertyr   r   r   r   r   r   %   s%      r   c                   "    e Zd ZdZd Zd Zd Zy)r   z=Handles authentication for services that use HTTP Basic Auth.c                      || _         || _        y)zConstructor.

        :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   s      r   __init__zBasicHttpAuthorizer.__init__M   s     ! r   c                     dt        j                  | j                  d| j                        j	                         z   |d<   y)zySet up credentials for a single request.

        This sets the authorization header with the username/password.
        zBasic :authorizationN)base64	b64encoder   r   stripr   s        r   r   z$BasicHttpAuthorizer.authorizeRequestV   s;     ==$--8eg 	 r   c                 P    |j                  | j                  | j                         y )N)add_credentialsr   r   r   s     r   r   z$BasicHttpAuthorizer.authorizeSessionb   s    t}}dmm<r   N)r   r   r   r   r    r   r   r   r   r   r   r   J   s    G!

=r   )r   type__metaclass____all__r$   r   r   r   r   r   <module>r,      s:   & 
 " "J=. =r   