-
Notifications
You must be signed in to change notification settings - Fork 45
Implement a Django authentication backend for NAV-style LDAP login flows #3624
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
base: master
Are you sure you want to change the base?
Conversation
12fddee to
720763d
Compare
Test results 27 files 27 suites 45m 43s ⏱️ Results for commit 8619aef. ♻️ This comment has been updated with latest results. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3624 +/- ##
==========================================
+ Coverage 62.49% 62.54% +0.04%
==========================================
Files 611 612 +1
Lines 45103 45153 +50
Branches 43 43
==========================================
+ Hits 28188 28241 +53
+ Misses 16905 16902 -3
Partials 10 10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
129f823 to
c45f372
Compare
720763d to
55c9d73
Compare
79e2568 to
1946a3c
Compare
Preparing a new LDAP authentication backend module for integrating NAV's LDAP authentication with Django. When finished, there should be no LDAP-specific stuff in the generic auth module.
a0b4085 to
78c2967
Compare
This `LdapBackend` can replace the existing legacy LDAP login flow in NAV, by re-using the `nav.web.auth.ldap` module, and without unnecessarily leaking LDAP abstractions and errors to the rest of the login system.
Grokking what this function did from its name wasn't all too easy. Also, given all the other methods of the LdapBackend class, it fit better as an extra method of that class. Additionally, added a more explicit docstring.
This ensures basic OpenLDAP library configuration is installed in the devcontainer. These configuration files are necessary in order to point the OpenLDAP library to the correct set of CA certificates to consider when verifying LDAP server connections. Without this, setting up NAV to authenticate against an SSL-protected LDAP server will just fail.
78c2967 to
27ba495
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this can safely be merged to master.
Then poc/allauth needs to move to the new master, and then rebase the dependents. (poc/django-auth-2, poc/allauth-dataporten, feature/enable-django-auth.. I think that's all of them.)
| def test_given_invalid_ldap_user_info_raise_permission_denied_exception( | ||
| self, mock_authenticate, db, ldap_synced_account | ||
| ): | ||
| mock_authenticate.side_effect = PermissionDenied |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes no sense. The low-level LDAP authenticate() function would never raise a Django specific exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(and I can't request changes when reviewing, since I originated this PR 😆 )



Scope and purpose
Fixes #3498.
This adds a new Django authentication backend implementation that reframes the legacy NAV LDAP authentication into Django's way of doing authentication.
The back-end is only implemented, not activated. Se subsequent PRs for this.
Contributor Checklist
Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to NAV can be found in the
Hacker's guide to NAV.
<major>.<minor>.x). For a new feature or other additions, it should be based onmaster.If applicable: Created new issues if this PR does not fix the issue completely/there is further work to be doneIf it's not obvious from a linked issue, described how to interact with NAV in order for a reviewer to observe the effects of this change first-hand (commands, URLs, UI interactions)If this results in changes in the UI: Added screenshots of the before and after