Skip to content

Commit 8bb0cba

Browse files
author
kkthxbye
committed
Fix #7751 - LDAP: Only get API user from ldap when FIND_GROUP_PERMS is enabled
1 parent 86ada33 commit 8bb0cba

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

netbox/netbox/api/authentication.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@ def authenticate_credentials(self, key):
2929
if settings.REMOTE_AUTH_BACKEND == 'netbox.authentication.LDAPBackend':
3030
from netbox.authentication import LDAPBackend
3131
ldap_backend = LDAPBackend()
32-
user = ldap_backend.populate_user(token.user.username)
33-
# If the user is found in the LDAP directory use it, if not fallback to the local user
34-
if user:
35-
return user, token
32+
33+
# Load from LDAP if FIND_GROUP_PERMS is active
34+
if ldap_backend.settings.FIND_GROUP_PERMS:
35+
user = ldap_backend.populate_user(token.user.username)
36+
# If the user is found in the LDAP directory use it, if not fallback to the local user
37+
if user:
38+
return user, token
3639

3740
return token.user, token
3841

0 commit comments

Comments
 (0)