nat.authentication.interfaces#

Attributes#

Classes#

AuthProviderBase

Base class for authenticating to API services.

FlowHandlerBase

Handles front-end specifc flows for authentication clients.

Module Contents#

AUTHORIZATION_HEADER = 'Authorization'#
class AuthProviderBase(
config: nat.data_models.authentication.AuthProviderBaseConfigT,
)#

Bases: Generic[nat.data_models.authentication.AuthProviderBaseConfigT], abc.ABC

Base class for authenticating to API services. This class provides an interface for authenticating to API services.

Initialize the AuthProviderBase with the given configuration.

Args:

config (AuthProviderBaseConfig): Configuration items for authentication.

_config#
property config: nat.data_models.authentication.AuthProviderBaseConfigT#

Returns the auth provider configuration object.

Returns#

AuthProviderBaseConfigT

The auth provider configuration object.

abstractmethod authenticate(
user_id: str | None = None,
) nat.data_models.authentication.AuthResult#
Async:

Perform the authentication process for the client.

This method handles the necessary steps to authenticate the client with the target API service, which may include obtaining tokens, refreshing credentials, or completing multi-step authentication flows.

Raises:

NotImplementedError: Must be implemented by subclasses.

class FlowHandlerBase#

Bases: abc.ABC

Handles front-end specifc flows for authentication clients.

Each front end will define a FlowHandler that will implement the authenticate method.

The authenticate method will be stored as the callback in the ContextState.user_auth_callback

abstractmethod authenticate(
config: nat.data_models.authentication.AuthProviderBaseConfig,
method: nat.data_models.authentication.AuthFlowType,
) nat.data_models.authentication.AuthenticatedContext#
Async:

Perform the authentication process for the client.

This method handles the necessary steps to authenticate the client with the target API service, which may include obtaining tokens, refreshing credentials, or completing multistep authentication flows.

Raises:

NotImplementedError: Must be implemented by subclasses.