Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Improve LDAP implementation to be standards compliant #13777

Merged
merged 21 commits into from Aug 11, 2021
Merged

feat: Improve LDAP implementation to be standards compliant #13777

merged 21 commits into from Aug 11, 2021

Conversation

jon-nfc
Copy link
Contributor

@jon-nfc jon-nfc commented Jul 26, 2021

Full proposal can be found in issue #13738

🔗 Related Items
Proposal: #13738
PR: #13777
📖 Documentation
ERPNext: PR frappe/erpnext_documentation#376
Frappe: PR frappe/frappe_docs#168

PR Tasks

docs: frappe/frappe_docs#168

Add new fields for the new group feature

issue #13738
New method to search for user group membership. Replaces old logic of using an ldap users attribute memberof which is not supported by all LDAP implementations

issue #13738
as part of the search the login/user name is required to find the user

issue #13738
adjusted to posixgroup as openldap groups use objectclass 'posixgroup' for both a posix group and a samba group.

issue #13738
All LDAP operations should be done by ldap base dn user. This allows an administrator to lock down their directory to the user the LDAP operations are being conducted by.

issue #13738
User needs to be able to conduct complex filtering. As long as the placeholder '{0}' for the username is included in the ldap search filter, the user can customize as required. searches must be enclosed in '()' i.e '(uid={0}) or '(&(objecttype=posixaccount)(uid={0}))' etc.

issue #13738 close #6037
Validate the LDAP search filter including enclosing in '()'. Note: if a user has a complex filter that misses the last ')' it will not be added. i.e. (&(objectclass=posixgroup)(uid={0}) is invalid but will pass validation.

issue #13738
ldap_group_field set for depreciation.

issue #13738 fixes #10794
to confirm user credentials, use 'rebind' instead of re-connecting to ldap. This also enables unit testing of all functions except the connection to ldap.

issue #13738
ldap search string is user input. validate to ensure is enclosed in '()', has the '{0}' placeholder and has the same number of brackets as used in complex ldap search strings.

issue #13738
A blank password causes exception 'ldap3.core.exceptions.LDAPPasswordIsMandatoryError'. Validate the user input.

Issue #13738
a user document is passed to the function. use this to derive user details

issue #13738
@jon-nfc jon-nfc changed the title Draft: [Proposal - issue 13738] Refactor LDAP feature: Improve LDAP implementation to be standards compliant Jul 26, 2021
@jon-nfc jon-nfc changed the title feature: Improve LDAP implementation to be standards compliant feat: Improve LDAP implementation to be standards compliant Jul 26, 2021
sider #issue-5810499
A user object is passed to the function. Use this to derived the user details.

PR #13777
As the user provides some of the ldap attributes, validate those entries when the 'LDAP Settings' editor clicks save. Provide an error message if validation fails stating what is incorrect.

issue #13738 PR-#13777
Function requires attributes to be of type x, validate to ensure any changes will break function and to prevent further exceptions. Only output to console as it's only a developer who will generate this error.

PR-#13777
@jon-nfc jon-nfc marked this pull request as ready for review July 27, 2021 09:21
@jon-nfc jon-nfc requested a review from leela as a code owner July 27, 2021 09:21
@jon-nfc
Copy link
Contributor Author

jon-nfc commented Jul 27, 2021

Docs are currently being worked on and will have PR done as soon as complete.

@mergify mergify bot merged commit be5f712 into frappe:develop Aug 11, 2021
@jon-nfc
Copy link
Contributor Author

jon-nfc commented Aug 11, 2021

now you can login with ldap. (posix.user1 - password1 or posix.user2 password2)

After trying it out on test servers, everything working as expected.

@revant

glad to hear.

do I need to create an additional PR for this to be added to version-13?

@jon-nfc
Copy link
Contributor Author

jon-nfc commented Aug 11, 2021

Bump,

What is the process to have this PR added to version 12 and 13?

@revant
Copy link
Collaborator

revant commented Aug 12, 2021

https://discuss.erpnext.com/t/hotfix-version-xx-develop-issue-pr-and-frappe-policies/78952/2

@mergify backport version-13

should create a PR

mergify bot pushed a commit that referenced this pull request Aug 12, 2021
A user object is passed to the function. Use this to derived the user details.

PR #13777

(cherry picked from commit c0565ae)
mergify bot pushed a commit that referenced this pull request Aug 12, 2021
As the user provides some of the ldap attributes, validate those entries when the 'LDAP Settings' editor clicks save. Provide an error message if validation fails stating what is incorrect.

issue #13738 PR-#13777

(cherry picked from commit 1b2ec4f)
mergify bot pushed a commit that referenced this pull request Aug 12, 2021
Function requires attributes to be of type x, validate to ensure any changes will break function and to prevent further exceptions. Only output to console as it's only a developer who will generate this error.

PR-#13777

(cherry picked from commit 99b1410)
mergify bot pushed a commit that referenced this pull request Aug 12, 2021
to prevent exceptions in other locations, validate the user and group search paths at the timeof input.

issue #13738 PR-#13777

(cherry picked from commit c37e16b)
mergify bot pushed a commit that referenced this pull request Aug 12, 2021
User can use any valid LDAP fdn to search. fields updated to refect.

issue #13738 PR-#13777

(cherry picked from commit 26b0fe3)
mergify bot pushed a commit that referenced this pull request Aug 12, 2021
Created unit tests for integration LDAP. These tests are designed to confirm that LDAP will continue to work after changes are made to frappe.

PR-#13777

(cherry picked from commit 172d1b3)

# Conflicts:
#	frappe/integrations/doctype/ldap_settings/test_ldap_settings.py
@mergify
Copy link
Contributor

mergify bot commented Aug 12, 2021

Command backport version-13: success

Backports have been created

Hey, I reacted but my real name is @Mergifyio

@ankush
Copy link
Member

ankush commented Aug 12, 2021

@mergify backport version-13-hotfix

mergify bot pushed a commit that referenced this pull request Aug 12, 2021
A user object is passed to the function. Use this to derived the user details.

PR #13777

(cherry picked from commit c0565ae)
mergify bot pushed a commit that referenced this pull request Aug 12, 2021
As the user provides some of the ldap attributes, validate those entries when the 'LDAP Settings' editor clicks save. Provide an error message if validation fails stating what is incorrect.

issue #13738 PR-#13777

(cherry picked from commit 1b2ec4f)
mergify bot pushed a commit that referenced this pull request Aug 12, 2021
Function requires attributes to be of type x, validate to ensure any changes will break function and to prevent further exceptions. Only output to console as it's only a developer who will generate this error.

PR-#13777

(cherry picked from commit 99b1410)
mergify bot pushed a commit that referenced this pull request Aug 12, 2021
to prevent exceptions in other locations, validate the user and group search paths at the timeof input.

issue #13738 PR-#13777

(cherry picked from commit c37e16b)
mergify bot pushed a commit that referenced this pull request Aug 12, 2021
User can use any valid LDAP fdn to search. fields updated to refect.

issue #13738 PR-#13777

(cherry picked from commit 26b0fe3)
mergify bot pushed a commit that referenced this pull request Aug 12, 2021
Created unit tests for integration LDAP. These tests are designed to confirm that LDAP will continue to work after changes are made to frappe.

PR-#13777

(cherry picked from commit 172d1b3)

# Conflicts:
#	frappe/integrations/doctype/ldap_settings/test_ldap_settings.py
@mergify
Copy link
Contributor

mergify bot commented Aug 12, 2021

Command backport version-13-hotfix: success

Backports have been created

Hey, I reacted but my real name is @Mergifyio

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants