소스 검색

Fix #7751 - LDAP: Only get API user from ldap when FIND_GROUP_PERMS is enabled

kkthxbye 4 년 전
부모
커밋
8bb0cba949
1개의 변경된 파일7개의 추가작업 그리고 4개의 파일을 삭제
  1. 7 4
      netbox/netbox/api/authentication.py

+ 7 - 4
netbox/netbox/api/authentication.py

@@ -29,10 +29,13 @@ class TokenAuthentication(authentication.TokenAuthentication):
         if settings.REMOTE_AUTH_BACKEND == 'netbox.authentication.LDAPBackend':
             from netbox.authentication import LDAPBackend
             ldap_backend = LDAPBackend()
-            user = ldap_backend.populate_user(token.user.username)
-            # If the user is found in the LDAP directory use it, if not fallback to the local user
-            if user:
-                return user, token
+
+            # Load from LDAP if FIND_GROUP_PERMS is active
+            if ldap_backend.settings.FIND_GROUP_PERMS:
+                user = ldap_backend.populate_user(token.user.username)
+                # If the user is found in the LDAP directory use it, if not fallback to the local user
+                if user:
+                    return user, token
 
         return token.user, token