mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 04:22:01 -06:00
Fixed bug for users authenticated with API token
This prevents a crash when the current user has authenticated himself with an API token. In this case the user will not have the permissions given to his LDAP groups.
This commit is contained in:
parent
5bf4234ad3
commit
4abfa6231c
@ -147,7 +147,9 @@ try:
|
|||||||
class NBLDAPBackend(ObjectPermissionMixin, LDAPBackend_):
|
class NBLDAPBackend(ObjectPermissionMixin, LDAPBackend_):
|
||||||
def get_permission_filter(self, user_obj):
|
def get_permission_filter(self, user_obj):
|
||||||
permission_filter = super().get_permission_filter(user_obj)
|
permission_filter = super().get_permission_filter(user_obj)
|
||||||
if self.settings.FIND_GROUP_PERMS:
|
if (self.settings.FIND_GROUP_PERMS and
|
||||||
|
hasattr(user_obj, "ldap_user") and
|
||||||
|
hasattr(user_obj.ldap_user, "group_names")):
|
||||||
permission_filter = permission_filter | Q(groups__name__in=user_obj.ldap_user.group_names)
|
permission_filter = permission_filter | Q(groups__name__in=user_obj.ldap_user.group_names)
|
||||||
return permission_filter
|
return permission_filter
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
|
Loading…
Reference in New Issue
Block a user