nat.front_ends.console.authentication_flow_handler#
Attributes#
Classes#
Authentication helper for CLI / console environments. Supports: |
Module Contents#
- logger#
- class _FlowState#
- future: asyncio.Future#
- class ConsoleAuthenticationFlowHandler#
Bases:
nat.authentication.interfaces.FlowHandlerBaseAuthentication 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).
- _create_authorization_url(
- client: authlib.integrations.httpx_client.AsyncOAuth2Client,
- config: nat.authentication.oauth2.oauth2_auth_code_flow_provider_config.OAuth2AuthCodeFlowProviderConfig,
- state: str,
- verifier: str | None = None,
- challenge: str | None = None,
Create OAuth authorization URL with proper error handling.
- Args:
client: The OAuth2 client instance config: OAuth2 configuration state: OAuth state parameter verifier: PKCE verifier (if using PKCE) challenge: PKCE challenge (if using PKCE)
- Returns:
The authorization URL
- 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 local server.
- Else → only build the redirect app and save it to
self._redirect_app for in‑process testing.
- Else → only build the redirect app and save it to