caosdb.connection.authentication.interface module

This module provides the interfaces for authenticating requests to the caosdb server.

Implementing modules muts provide a get_authentication_provider() method.

class caosdb.connection.authentication.interface.AbstractAuthenticator

Bases: abc.ABC

AbstractAuthenticator.

Interface for different authentication mechanisms. e.g. username/password authentication or SSH key authentication.

logger

A logger which should be used for all logging which has to do with authentication.

Type

Logger

auth_token

A string representation of a CaosDB Auth Token.

Type

str

login(abstract)
logout(abstract)
configure(abstract)
on_request()
on_response()
abstract configure(**config)

configure.

Configure this authenticator.

Parameters

**config – Keyword arguments for the configuration.

Returns

Return type

None

abstract login()

login.

To be implemented by the child classes.

Returns

Return type

None

abstract logout()

logout.

To be implemented by the child classes.

Returns

Return type

None

on_request(method, path, headers, **kwargs)

on_request.

A call-back which is to be called by the connection before each request. This method set the auth cookie for that request.

Parameters
  • method (str) – The request method.

  • path (str) – The request path.

  • headers (dict) – A dictionary with headers which are to be set.

  • **kwargs – Ignored

on_response(response)

on_response.

A call-back with is to be called by the connection after each response. This method reads the latest auth cookie from the response.

Parameters

response (CaosDBHTTPResponse) – The response of the server

class caosdb.connection.authentication.interface.CredentialsAuthenticator(credentials_provider)

Bases: caosdb.connection.authentication.interface.AbstractAuthenticator

CredentialsAuthenticator.

Subclass of AbstractAuthenticator which provides authentication via credentials (username/password). This class always needs a credentials_provider which provides valid credentials_provider before each login.

Parameters

credentials_provider (CredentialsProvider) – The source for the username and the password.

login()
logout()
configure()
configure(**config)

configure.

Configure this authenticator.

Parameters

**config – Keyword arguments for the configuration.

Returns

Return type

None

login()

login.

To be implemented by the child classes.

Returns

Return type

None

logout()

logout.

To be implemented by the child classes.

Returns

Return type

None

class caosdb.connection.authentication.interface.CredentialsProvider

Bases: abc.ABC

CredentialsProvider.

An abstract class for username/password authentication.

password(abstract)
username(abstract)
logger

A logger which should be used for all logging which has to do with the provision of credentials. This is usually just the “authentication” logger.

Type

Logger

configure(abstract)
abstract configure(**config)

configure.

Configure the credentials provider with a dict.

Parameters

**config – Keyword arguments. The relevant arguments depend on the implementing subclass of this class.

Returns

Return type

None

abstract property password

password.

abstract property username

username.