CredentialStore

class pyvo.auth.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(method_uri)

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

negotiate_method(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(method_uri, session)

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

set_client_certificate(certificate_path)

Add a client certificate to use for authentication.

set_cookie(cookie_name, cookie_value[, ...])

Add a cookie to use as authentication.

set_cookie_jar(cookie_jar)

Set the cookie jar to use for authentication.

set_password(username, password)

Add a username / password for basic authentication.

Methods Documentation

get(method_uri)[source]

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

Parameters
method_uristr

URI representing the security method

negotiate_method(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_methodslist(str)

list of allowed security methods to return

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

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

Parameters
method_uristr

URI representing the security method

sessionobject

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

set_client_certificate(certificate_path)[source]

Add a client certificate to use for authentication.

Parameters
certificate_pathstr

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_namestr

name of the cookie

cookie_valuestr

value of the cookie

domainstr

restrict usage of this cookie to this domain

pathstr

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_jarobj

the cookie jar to use.

set_password(username, password)[source]

Add a username / password for basic authentication.

Parameters
usernamestr

username to use

passwordstr

password to use