feat(auth): add LdapAuth class for LDAP-based authentication#55
Open
victorvhs017 wants to merge 1 commit intomainfrom
Open
feat(auth): add LdapAuth class for LDAP-based authentication#55victorvhs017 wants to merge 1 commit intomainfrom
victorvhs017 wants to merge 1 commit intomainfrom
Conversation
Contributor
Greptile OverviewGreptile SummaryAdded LDAP authentication support for machine identities, following the established pattern used by other auth methods ( Changes:
Review Notes:
Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 108a5b5 |
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 |
Contributor
There was a problem hiding this comment.
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add LDAP Authentication Support
Adds LDAP authentication method for machine identities, bringing Python SDK to feature parity with the Go SDK.
Changes
LdapAuthclass ininfisical_sdk/resources/auth_methods/ldap_auth.pyAuthclassUsage