Skip to content

Commit d5f308d

Browse files
Merge pull request #7928 from kkthxbye-code/fix-7751
Fix #7751: LDAP: Only get API user from ldap when FIND_GROUP_PERMS is on
2 parents 1377eda + 8bb0cba commit d5f308d

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)