nat.front_ends.fastapi.auth_flow_handlers.websocket_flow_handler#

Attributes#

Classes#

FlowState

WebSocketAuthenticationFlowHandler

Handles front-end specifc flows for authentication clients.

Module Contents#

logger#
class FlowState#
future: asyncio.Future#
challenge: str | None = None#
verifier: str | None = None#
client: authlib.integrations.httpx_client.AsyncOAuth2Client | None = None#
config: nat.authentication.oauth2.oauth2_auth_code_flow_provider_config.OAuth2AuthCodeFlowProviderConfig | None = None#
class WebSocketAuthenticationFlowHandler(
add_flow_cb: collections.abc.Callable[[str, FlowState], collections.abc.Awaitable[None]],
remove_flow_cb: collections.abc.Callable[[str], collections.abc.Awaitable[None]],
web_socket_message_handler: nat.front_ends.fastapi.message_handler.WebSocketMessageHandler,
)#

Bases: nat.authentication.interfaces.FlowHandlerBase

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

_add_flow_cb: collections.abc.Callable[[str, FlowState], collections.abc.Awaitable[None]]#
_remove_flow_cb: collections.abc.Callable[[str], collections.abc.Awaitable[None]]#
_web_socket_message_handler: nat.front_ends.fastapi.message_handler.WebSocketMessageHandler#
async authenticate(
config: nat.authentication.oauth2.oauth2_auth_code_flow_provider_config.OAuth2AuthCodeFlowProviderConfig,
method: nat.data_models.authentication.AuthFlowType,
) nat.data_models.authentication.AuthenticatedContext#

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.

create_oauth_client(
config: nat.authentication.oauth2.oauth2_auth_code_flow_provider_config.OAuth2AuthCodeFlowProviderConfig,
)#
async _handle_oauth2_auth_code_flow(
config: nat.authentication.oauth2.oauth2_auth_code_flow_provider_config.OAuth2AuthCodeFlowProviderConfig,
) nat.data_models.authentication.AuthenticatedContext#