devo_ml.modelmanager.auth#

Supported authentication methods of ML Model Manager.

AuthCallable#

Signature type for callable authentications.

alias of Callable[[PreparedRequest], PreparedRequest]

BEARER = 'bearer'#

Constant denoting authentication type Bearer.

STANDALONE = 'standalone'#

Constant denoting authentication type StandAlone.

get_default_auth_type()[source]#

Returns the default authentication type used.

Return type:

str

Returns:

The default authentication

validate_auth_type(auth_type)[source]#

Checks whether a value is a valid authentication type.

Parameters:

auth_type (str) – The value to validate

Return type:

bool

Returns:

True if the value is a valid authentication type otherwise False

create_auth_from_token(token, auth_type='standalone')[source]#

Creates an authentication object based on a token ready to use by the client.

Parameters:
  • token (str) – The token to authenticate

  • auth_type (str) – The type of the authentication, defaults to STANDALONE

Raises:

ValueError – if auth_type is not valid

Return type:

Callable[[PreparedRequest], PreparedRequest]

Returns:

An authentication object

class HttpDevoTokenAuth(token)[source]#

An HTTP authentication scheme based on a token supported by ML Model Manager.

The implementations of this class are objects ready to use by the client to authenticate and also by Requests library.

__init__(token)[source]#

Creates an authentication base on a token.

Parameters:

token (str) – The token used

abstract __call__(req)[source]#

Subclasses must implement this method to client be able to call it as a function when authenticate a request.

Parameters:

req (PreparedRequest) – The request object to authenticate

Return type:

PreparedRequest

Returns:

The request object authenticated

class HttpDevoStandAloneTokenAuth(token)[source]#

An HttpDevoTokenAuth that authenticates a request with HTTP Devo Standalone authentication scheme.

__call__(req)[source]#

Adds the header standAloneToken: <token> to the request.

Parameters:

req (PreparedRequest) – The request object to authenticate

Return type:

PreparedRequest

Returns:

The request object authenticated with proper header

class HttpDevoBearerTokenAuth(token)[source]#

An HttpDevoTokenAuth that authenticates a request with HTTP Bearer authentication scheme.

__call__(req)[source]#

Adds the header Authorization: Bearer <token> to the request.

Parameters:

req (PreparedRequest) – The request object to authenticate

Return type:

PreparedRequest

Returns:

The request object authenticated with proper header