aistore.sdk.authn.authn_client

View as Markdown

Module Contents

Classes

NameDescription
AuthNClientAuthN client for managing authentication.

Data

logger

API

class aistore.sdk.authn.authn_client.AuthNClient(
endpoint: str,
skip_verify: bool = False,
ca_cert: typing.Optional[str] = None,
timeout: typing.Optional[typing.Union[float, typing.Tuple[float, float]]] = None,
retry: typing.Optional[urllib3.Retry] = None,
token: typing.Optional[str] = None
)

AuthN client for managing authentication.

This client provides methods to interact with AuthN Server. For more info on AuthN Server, see https://github.com/NVIDIA/aistore/blob/main/docs/authn.md

Parameters:

endpoint
str

AuthN service endpoint URL.

skip_verify
boolDefaults to False

If True, skip SSL certificate verification. Defaults to False.

ca_cert
strDefaults to None

Path to a CA certificate file for SSL verification.

timeout
Union[float, Tuple[float, float], None]Defaults to None

Request timeout in seconds; a single float for both connect/read timeouts (e.g., 5.0), a tuple for separate connect/read timeouts (e.g., (3.0, 10.0)), or None to disable timeout.

retry
urllib3.RetryDefaults to None

Retry configuration object from the urllib3 library.

token
strDefaults to None

Authorization token.

_request_client
client
RequestClient

Get the request client.

aistore.sdk.authn.authn_client.AuthNClient.cluster_manager() -> aistore.sdk.authn.cluster_manager.ClusterManager

Factory method to create a ClusterManager instance.

Returns: ClusterManager

An instance to manage cluster operations.

aistore.sdk.authn.authn_client.AuthNClient.login(
username: str,
password: str,
expires_in: typing.Optional[typing.Union[int, float]] = None
) -> str

Logs in to the AuthN Server and returns an authorization token.

Parameters:

username
str

The username to log in with.

password
str

The password to log in with.

expires_in
Optional[Union[int, float]]Defaults to None

The expiration duration of the token in seconds.

Returns: str

An authorization token to use for future requests.

Raises:

  • ValueError: If the password is empty or consists only of spaces.
  • Exception: If the login request fails or any other error occurs.
aistore.sdk.authn.authn_client.AuthNClient.logout() -> None

Logs out and revokes current token from the AuthN Server.

Raises:

  • ValueError: If no token is available (not logged in).
  • Exception: If the logout request fails or any other error occurs.
aistore.sdk.authn.authn_client.AuthNClient.role_manager() -> aistore.sdk.authn.role_manager.RoleManager

Factory method to create a RoleManager instance.

Returns: RoleManager

An instance to manage role operations.

aistore.sdk.authn.authn_client.AuthNClient.token_manager() -> aistore.sdk.authn.token_manager.TokenManager

Factory method to create a TokenManager instance.

Returns: TokenManager

An instance to manage token operations.

aistore.sdk.authn.authn_client.AuthNClient.user_manager() -> aistore.sdk.authn.user_manager.UserManager

Factory method to create a UserManager instance.

Returns: UserManager

An instance to manage user operations.

aistore.sdk.authn.authn_client.logger = get_logger(__name__)