Skip to content

Commit 2d5c453

Browse files
authored
Merge pull request #1307 from netbox-community/revert-1297-feat/multiple-ldap-require-dn
Revert "Feature: Support for multiple AUTH_LDAP_REQUIRE_GROUP from environment variables"
2 parents 52f38a3 + 942f978 commit 2d5c453

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

configuration/ldap/extra.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
####
22
## This file contains extra configuration options that can't be configured
33
## directly through environment variables.
4-
## All variables set here overwrite any existing found in ldap_config.py
4+
## All vairables set here overwrite any existing found in ldap_config.py
55
####
66

77
# # This Python script inherits all the imports from ldap_config.py
8+
# from django_auth_ldap.config import LDAPGroupQuery # Imported since not in ldap_config.py
89

910
# # Sets a base requirement of membetship to netbox-user-ro, netbox-user-rw, or netbox-user-admin.
1011
# AUTH_LDAP_REQUIRE_GROUP = (

configuration/ldap/ldap_config.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from os import environ
33

44
import ldap
5-
from django_auth_ldap.config import LDAPGroupQuery, LDAPSearch
5+
from django_auth_ldap.config import LDAPSearch
66

77

88
# Read secret from file
@@ -86,22 +86,12 @@ def _import_group_type(group_type_name):
8686
# Define a group required to login.
8787
AUTH_LDAP_REQUIRE_GROUP = environ.get('AUTH_LDAP_REQUIRE_GROUP_DN')
8888

89-
# If non-empty string, AUTH_LDAP_REQUIRE_GROUP will be treated as a list delimited by this separator
90-
AUTH_LDAP_REQUIRE_GROUP_SEPARATOR = environ.get('AUTH_LDAP_REQUIRE_GROUP_DN_SEPARATOR', '')
91-
9289
# Define special user types using groups. Exercise great caution when assigning superuser status.
9390
AUTH_LDAP_USER_FLAGS_BY_GROUP = {}
9491

9592
if AUTH_LDAP_REQUIRE_GROUP is not None:
96-
# Build an LDAPGroupQuery when AUTH_LDAP_REQUIRE_GROUP should be treated as a list
97-
if AUTH_LDAP_REQUIRE_GROUP_SEPARATOR:
98-
_groups = list(filter(None, AUTH_LDAP_REQUIRE_GROUP.split(AUTH_LDAP_REQUIRE_GROUP_SEPARATOR)))
99-
AUTH_LDAP_REQUIRE_GROUP = LDAPGroupQuery(_groups[0])
100-
for i in range(1, len(_groups)):
101-
AUTH_LDAP_REQUIRE_GROUP |= LDAPGroupQuery(_groups[i])
102-
10393
AUTH_LDAP_USER_FLAGS_BY_GROUP = {
104-
"is_active": AUTH_LDAP_REQUIRE_GROUP,
94+
"is_active": environ.get('AUTH_LDAP_REQUIRE_GROUP_DN', ''),
10595
"is_staff": environ.get('AUTH_LDAP_IS_ADMIN_DN', ''),
10696
"is_superuser": environ.get('AUTH_LDAP_IS_SUPERUSER_DN', '')
10797
}

0 commit comments

Comments
 (0)