Skip to content

feat(auth): add LdapAuth class for LDAP-based authentication#55

Open
victorvhs017 wants to merge 1 commit intomainfrom
feature/python-ldap-login
Open

feat(auth): add LdapAuth class for LDAP-based authentication#55
victorvhs017 wants to merge 1 commit intomainfrom
feature/python-ldap-login

Conversation

@victorvhs017
Copy link
Contributor

Add LDAP Authentication Support

Adds LDAP authentication method for machine identities, bringing Python SDK to feature parity with the Go SDK.

Changes

  • Added LdapAuth class in infisical_sdk/resources/auth_methods/ldap_auth.py
  • Registered LDAP auth in the Auth class

Usage

client = InfisicalSDKClient(host="http://localhost:8080")
result = client.auth.ldap_auth.login(
    identity_id="your-identity-id",
    username="ldap-username",
    password="ldap-password"
)

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 13, 2026

Greptile Overview

Greptile Summary

Added LDAP authentication support for machine identities, following the established pattern used by other auth methods (UniversalAuth, OidcAuth, AWSAuth).

Changes:

  • Created new LdapAuth class with login() method accepting identity_id, username, and password
  • Registered LDAP auth in the main Auth class alongside existing methods
  • Implementation correctly uses the InfisicalRequests wrapper and MachineIdentityLoginResponse model
  • Code follows the exact same pattern as OidcAuth and UniversalAuth implementations

Review Notes:

  • Implementation is clean, secure, and consistent with existing codebase patterns
  • No security issues detected - credentials are sent via HTTPS POST to the API endpoint
  • No breaking API changes introduced
  • Check that external documentation has been updated for discoverability

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation is clean, follows established patterns exactly, introduces no breaking changes, and adds straightforward LDAP authentication support. No security vulnerabilities or logical errors detected.
  • No files require special attention

Important Files Changed

Filename Overview
infisical_sdk/resources/auth_methods/ldap_auth.py New LDAP authentication implementation following existing patterns, no issues found
infisical_sdk/resources/auth.py Added LdapAuth registration, consistent with existing auth methods
infisical_sdk/resources/auth_methods/init.py Added LdapAuth export, follows module pattern correctly

Last reviewed commit: 108a5b5

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

3 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +1 to +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
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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant