From 7b03f719d6130991c00dc90355c102688db93133 Mon Sep 17 00:00:00 2001 From: Victor Santos Date: Thu, 27 Nov 2025 15:25:23 -0300 Subject: [PATCH 1/2] feat(auth): add TokenAuth class for token-based authentication --- infisical_sdk/resources/auth.py | 5 +++- .../resources/auth_methods/__init__.py | 1 + .../resources/auth_methods/token_auth.py | 24 +++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 infisical_sdk/resources/auth_methods/token_auth.py diff --git a/infisical_sdk/resources/auth.py b/infisical_sdk/resources/auth.py index ece95c2..83bb1cc 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(requests, 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..e8066a1 --- /dev/null +++ b/infisical_sdk/resources/auth_methods/token_auth.py @@ -0,0 +1,24 @@ +from typing import Callable +from infisical_sdk.infisical_requests import InfisicalRequests + +class TokenAuth: + def __init__(self, requests: InfisicalRequests, setToken: Callable[[str], None]): + self.requests = requests + 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 + From aa2d0c6cd41dc473e5ec992c2413921a6ee7c5ef Mon Sep 17 00:00:00 2001 From: Victor Santos Date: Thu, 27 Nov 2025 15:39:43 -0300 Subject: [PATCH 2/2] refactor(auth): simplify TokenAuth initialization by removing requests parameter --- infisical_sdk/resources/auth.py | 2 +- infisical_sdk/resources/auth_methods/token_auth.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/infisical_sdk/resources/auth.py b/infisical_sdk/resources/auth.py index 83bb1cc..c45e620 100644 --- a/infisical_sdk/resources/auth.py +++ b/infisical_sdk/resources/auth.py @@ -11,4 +11,4 @@ def __init__(self, requests: InfisicalRequests, setToken: Callable[[str], None]) self.aws_auth = AWSAuth(requests, setToken) self.universal_auth = UniversalAuth(requests, setToken) self.oidc_auth = OidcAuth(requests, setToken) - self.token_auth = TokenAuth(requests, setToken) \ No newline at end of file + self.token_auth = TokenAuth(setToken) \ No newline at end of file diff --git a/infisical_sdk/resources/auth_methods/token_auth.py b/infisical_sdk/resources/auth_methods/token_auth.py index e8066a1..3987d5e 100644 --- a/infisical_sdk/resources/auth_methods/token_auth.py +++ b/infisical_sdk/resources/auth_methods/token_auth.py @@ -1,9 +1,7 @@ from typing import Callable -from infisical_sdk.infisical_requests import InfisicalRequests class TokenAuth: - def __init__(self, requests: InfisicalRequests, setToken: Callable[[str], None]): - self.requests = requests + def __init__(self, setToken: Callable[[str], None]): self.setToken = setToken def login(self, token: str) -> str: