nat.front_ends.console.authentication_flow_handler#
Classes#
Authentication helper for CLI / console environments. Supports: |
Module Contents#
- class _FlowState#
- future: asyncio.Future#
- class ConsoleAuthenticationFlowHandler#
Bases:
nat.authentication.interfaces.FlowHandlerBase
Authentication helper for CLI / console environments. Supports:
HTTP Basic (username/password)
OAuth 2 Authorization‑Code with optional PKCE
- _server_controller: nat.front_ends.fastapi.fastapi_front_end_controller._FastApiFrontEndController | None = None#
- _flows: dict[str, _FlowState]#
- _active_flows = 0#
- _server_lock#
- async authenticate(
- config: nat.data_models.authentication.AuthProviderBaseConfig,
- method: nat.data_models.authentication.AuthFlowType,
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.
- construct_oauth_client(
- cfg: nat.authentication.oauth2.oauth2_auth_code_flow_provider_config.OAuth2AuthCodeFlowProviderConfig,
Separated for easy overriding in tests (to inject ASGITransport).
- static _handle_http_basic() nat.data_models.authentication.AuthenticatedContext #
- async _handle_oauth2_auth_code_flow(
- cfg: nat.authentication.oauth2.oauth2_auth_code_flow_provider_config.OAuth2AuthCodeFlowProviderConfig,
- async _build_redirect_app() fastapi.FastAPI #
If cfg.run_redirect_local_server == True → start a uvicorn server (old behaviour).
- Else → only build the FastAPI app and save it to
self._redirect_app
for in‑process testing with ASGITransport.
- Else → only build the FastAPI app and save it to