Skip to content
Open
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
4 changes: 3 additions & 1 deletion infisical_sdk/resources/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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 infisical_sdk.resources.auth_methods import LdapAuth
from typing import Callable

class Auth:
Expand All @@ -11,4 +12,5 @@ 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(setToken)
self.token_auth = TokenAuth(setToken)
self.ldap_auth = LdapAuth(requests, setToken)
1 change: 1 addition & 0 deletions infisical_sdk/resources/auth_methods/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
from .universal_auth import UniversalAuth
from .oidc_auth import OidcAuth
from .token_auth import TokenAuth
from .ldap_auth import LdapAuth
38 changes: 38 additions & 0 deletions infisical_sdk/resources/auth_methods/ldap_auth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from infisical_sdk.api_types import MachineIdentityLoginResponse

from typing import Callable
from infisical_sdk.infisical_requests import InfisicalRequests

class LdapAuth:
def __init__(self, requests: InfisicalRequests, setToken: Callable[[str], None]):
self.requests = requests
self.setToken = setToken

def login(self, identity_id: str, username: str, password: str) -> MachineIdentityLoginResponse:
"""
Login with LDAP Auth.

Args:
identity_id (str): Your Machine Identity ID.
username (str): Your LDAP username.
password (str): Your LDAP password.

Returns:
MachineIdentityLoginResponse: A response containing the access token and related information.
"""

requestBody = {
"identityId": identity_id,
"username": username,
"password": password
}

result = self.requests.post(
path="/api/v1/auth/ldap-auth/login",
json=requestBody,
model=MachineIdentityLoginResponse
)

self.setToken(result.data.accessToken)

return result.data
Comment on lines +1 to +38
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check that the SDK documentation at https://infisical.com/docs/sdks/languages/python has been updated to include LDAP auth usage examples so customers can discover this feature.

Context Used: Context from dashboard - When naming sections in documentation, use clear and descriptive titles that reflect the functionali... (source)