CredentialStore

class pyvo.auth.credentialstore.CredentialStore[source]

Bases: object

The credential store takes user credentials, and uses them to create appropriate requests sessions for dispatching requests using those credentials.

Different types of credentials can be passed in, such as cookies, a jar of cookies, certificates, and basic auth.

A session can also be associated with a security method URI by calling the set function.

Before a request is to be dispatched, the AuthSession calls the get method to retrieve the appropriate requests.Session for making that HTTP request.

Methods Summary

get(self, method_uri) Retrieve the requests.Session like object associated with a security method URI.
negotiate_method(self, allowed_methods) Compare the credentials provided by the user against the security methods passed in, and determine which method is to be used for making this request.
set(self, method_uri, session) Associate a security method URI with a requests.Session like object.
set_client_certificate(self, certificate_path) Add a client certificate to use for authentication.
set_cookie(self, cookie_name, cookie_value) Add a cookie to use as authentication.
set_cookie_jar(self, cookie_jar) Set the cookie jar to use for authentication.
set_password(self, username, password) Add a username / password for basic authentication.

Methods Documentation

get(self, method_uri)[source]

Retrieve the requests.Session like object associated with a security method URI.

Parameters:
method_uri : str

URI representing the security method

negotiate_method(self, allowed_methods)[source]

Compare the credentials provided by the user against the security methods passed in, and determine which method is to be used for making this request.

Parameters:
allowed_methods : list(str)

list of allowed security methods to return

Raises:
Raises an exception if a common method could not be negotiated.
set(self, method_uri, session)[source]

Associate a security method URI with a requests.Session like object.

Parameters:
method_uri : str

URI representing the security method

session : object

the requests.Session like object that will dispatch requests for the authentication method provided by method_uri

set_client_certificate(self, certificate_path)[source]

Add a client certificate to use for authentication.

Parameters:
certificate_path : str

path to the file of the client certificate

Add a cookie to use as authentication.

More than one call to set_cookie will add multiple cookies into the same cookie jar used for the request.

Parameters:
cookie_name : str

name of the cookie

cookie_value : str

value of the cookie

domain : str

restrict usage of this cookie to this domain

path : str

restrict usage of this cookie to this path

Set the cookie jar to use for authentication.

Any previous cookies or cookie jars set will be removed.

Parameters:
cookie_jar : obj

the cookie jar to use.

set_password(self, username, password)[source]

Add a username / password for basic authentication.

Parameters:
username : str

username to use

password : str

password to use