-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Integration with AUTH_LDAP_FIND_GROUP_PERMS does not work #5442
Comments
NetBox v2.9 introduced object-based permissions, which employ a custom ObjectPermission model rather than Django's built-in Permission. NetBox's LDAPBackend class likely needs to be extended to support the described behavior. Marking this as |
This might be a duplicate of #5125. |
@jeremystretch yep, that seems to be same case, though linked ticket is missing information why it is broken so if you decide to close one as dupe of another - IMO would be better to close that one as a duplicate (even though it is older).
Do you have any hint about this? I could try to make a patch, but quick look into the code does not help me to guess even where to look. |
I wasn't able to replicate this on v2.10.2: The group assignment works automatically as expected. Here's what I did:
The LDAP user account is automatically created and assigned to the specified group. After logging in as the user, I am granted the permissions assigned to the group. Here's my LDAP configuration:
Note that I'm using |
I believe this is the key. This will sync all groups of a user into the netbox and will "add user to the group". https://django-auth-ldap.readthedocs.io/en/latest/permissions.html#group-mirroring
@jeremystretch , it is supposed to work without that option but that is not compatible with netbox user backend. |
Ok, I think I see the disconnect. My expectation is just to have the LDAP user assigned to the groups that exist in Django, so that it gets granted the associated permissions by proxy. But it looks like you're trying to assign those permissions to the user directly? As you point out, django-auth-ldap's |
If I understand how |
That's my impression as well. This seems undesirable, though: IMO I'd rather just assign the user to the appropriate Django group(s) so that they inherit all associated permissions assigned to each group. It looks like |
@jeremystretch I don't think it actually "assigns" them. It just overrides "get_group_permissions()" from Django to return "extra" permissions without assigning user to a group. So it actually does not modify permissions DB at all, merely just returns more permissions on the fly. That seems quite desirable because you don't have to force re-login users when you change some group assignment and so on. |
Hey, any update on this ? I dont want all of the ldap groups to be created in netbox wirh 'AUTH_LDAP_MIRROR_GROUPS ' |
We are also facing this issue. We've started on 2.10 with a blank installation and neither As @PieterL75 we've tried numerous combinations of DNs, plain "True" on While testing, we've debug-logged django-auth-ldap & Django and ran Netbox itself in debug-Mode, but no error messages were thrown on logins. Logs show, that all infos on a DN are found and processed. @PieterL75 Edit: We've had a pretty obvious configuration issue in our deployment, soooo... MIRROR_GROUPS is working flawlessy now. :) |
Mirror groups does seem to workaround this issue (and other LDAP issues I've had) - however I'd recommend also setting I'd initially not used the group mirroring since the However - in NetBox's case |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our contributing guide. |
Please don't close it as it is real issue. |
@ignatenkobrain would you like to volunteer to work on this? |
I have created PR #6580 which fixes this issue in our environment. @ignatenkobrain @tyler-8 Could you try to run your system with the changes and verify if they work for you? |
LGTM from the NetBox side but will wait for confirmation from others. |
If you can wait a couple days I'd be happy to test out the change. |
I ran into an issue with the PR and noted the error and steps to reproduce: #6580 (comment) |
Fixes #5442: Use LDAP groups to find permissions
When AUTH_LDAP_FIND_GROUP_PERMS is set to true the filter to find the users permissions is extended to search for all permissions assigned to groups in which the LDAP user is.
Environment
Steps to Reproduce
AUTH_LDAP_FIND_GROUP_PERMS
django-auth-ldap
moduleExpected Behavior
User is able to use those permissions.
Observed Behavior
User is getting permission denied on creating api token.
Analyze
I've spent many hours trying to find out why users can't have permissions in our netbox installation but it does seem to me like a bug in Netbox.
What django-auth-ldap is doing:
Here it gets empty
QuerySet
.Enabling
DEBUG
and inspecting SQL:It is trying to get info from the
auth_group_permissions
, but inspecting the database it shows completely empty table. Even there is some permissions assigned to the group.Dumping the DB, removing group permission, dumping DB again and comparing shows something interesting:
So it does change
users_objectpermission_groups
and not theauth_permission_groups
. And that's why django-auth-ldap can't find any permissions (without explicitly creating group).Seems that
ObjectPermissionBackend
written in netbox is behaving differently than the standard django one.The text was updated successfully, but these errors were encountered: