nat.authentication.api_key.api_key_auth_provider#
Attributes#
Classes#
Base class for authenticating to API services. |
Module Contents#
- logger#
- class APIKeyAuthProvider(
- config: nat.authentication.api_key.api_key_auth_provider_config.APIKeyAuthProviderConfig,
- config_name: str | None = None,
Bases:
nat.authentication.interfaces.AuthProviderBase
[nat.authentication.api_key.api_key_auth_provider_config.APIKeyAuthProviderConfig
]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.
- async _construct_authentication_header() nat.data_models.authentication.BearerTokenCred #
Constructs the authenticated HTTP header based on the authentication scheme. Basic Authentication follows the OpenAPI 3.0 Basic Authentication standard as well as RFC 7617.
- Args:
- header_auth_scheme (HeaderAuthScheme): The HTTP authentication scheme to use.
Supported schemes: BEARER, X_API_KEY, BASIC, CUSTOM.
- Returns:
- BearerTokenCred: The HTTP headers containing the authentication credentials.
Returns None if the scheme is not supported or configuration is invalid.
- async authenticate( ) nat.data_models.authentication.AuthResult | None #
Authenticate the user using the API key credentials.
- Args:
user_id (str): The user ID to authenticate.
- Returns:
AuthenticatedContext: The authenticated context containing headers, query params, cookies, etc.