mirror of
https://github.com/hanzokms/python-sdk.git
synced 2026-10-30 20:30:11 +00:00
- Rename package: infisical_sdk -> hanzo_kms (pip: hanzokms) - Rename classes: InfisicalSDKClient -> KMSClient, InfisicalRequests -> KMSRequests, InfisicalError -> KMSError - Default API host: https://kms.hanzo.ai - Update all imports, docstrings, and user-facing strings - Copyright: Hanzo AI Inc. - Backward-compatible aliases: InfisicalSDKClient, InfisicalError - Env var: INFISICAL_AWS_IAM_AUTH_IDENTITY_ID -> HANZO_KMS_AWS_IAM_AUTH_IDENTITY_ID - Remove obsolete OpenAPI generator files (.travis.yml, .gitlab-ci.yml, etc.)
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
from hanzo_kms.api_types import MachineIdentityLoginResponse
|
|
|
|
from typing import Callable
|
|
from hanzo_kms.kms_requests import KMSRequests
|
|
|
|
class LdapAuth:
|
|
def __init__(self, requests: KMSRequests, 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
|