diff --git a/infisical_sdk/resources/auth.py b/infisical_sdk/resources/auth.py index ece95c2..c45e620 100644 --- a/infisical_sdk/resources/auth.py +++ b/infisical_sdk/resources/auth.py @@ -2,10 +2,13 @@ from infisical_sdk.resources.auth_methods import AWSAuth from infisical_sdk.resources.auth_methods import UniversalAuth from infisical_sdk.resources.auth_methods import OidcAuth +from infisical_sdk.resources.auth_methods import TokenAuth from typing import Callable + class Auth: def __init__(self, requests: InfisicalRequests, setToken: Callable[[str], None]): self.requests = requests self.aws_auth = AWSAuth(requests, setToken) self.universal_auth = UniversalAuth(requests, setToken) - self.oidc_auth = OidcAuth(requests, setToken) \ No newline at end of file + self.oidc_auth = OidcAuth(requests, setToken) + self.token_auth = TokenAuth(setToken) \ No newline at end of file diff --git a/infisical_sdk/resources/auth_methods/__init__.py b/infisical_sdk/resources/auth_methods/__init__.py index d5eed91..15ef503 100644 --- a/infisical_sdk/resources/auth_methods/__init__.py +++ b/infisical_sdk/resources/auth_methods/__init__.py @@ -1,3 +1,4 @@ from .aws_auth import AWSAuth from .universal_auth import UniversalAuth from .oidc_auth import OidcAuth +from .token_auth import TokenAuth diff --git a/infisical_sdk/resources/auth_methods/token_auth.py b/infisical_sdk/resources/auth_methods/token_auth.py new file mode 100644 index 0000000..3987d5e --- /dev/null +++ b/infisical_sdk/resources/auth_methods/token_auth.py @@ -0,0 +1,22 @@ +from typing import Callable + +class TokenAuth: + def __init__(self, setToken: Callable[[str], None]): + self.setToken = setToken + + def login(self, token: str) -> str: + """ + Authenticate using a token. This can be either a machine identity token or a user JWT token. + + Machine Identity Token: Generated from Token Auth method in Infisical. + User JWT Token: A valid JWT token for user authentication. + + Args: + token (str): Your authentication token (machine identity token or user JWT). + + Returns: + str: The token that was set. + """ + self.setToken(token) + return token +