Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion infisical_sdk/resources/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
self.oidc_auth = OidcAuth(requests, setToken)
self.token_auth = TokenAuth(setToken)
1 change: 1 addition & 0 deletions infisical_sdk/resources/auth_methods/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .aws_auth import AWSAuth
from .universal_auth import UniversalAuth
from .oidc_auth import OidcAuth
from .token_auth import TokenAuth
22 changes: 22 additions & 0 deletions infisical_sdk/resources/auth_methods/token_auth.py
Original file line number Diff line number Diff line change
@@ -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