Skip to content

Commit 81bcb71

Browse files
committed
Users only belong to automatic groups if the group is retrieved from the correct source. Fixes ietf-tools#360
- Legacy-Id: 2477
1 parent 915c93c commit 81bcb71

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

ietf/ietfauth/auth.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939

4040
from ietf.utils import log
4141

42+
AUTOMATIC_GROUPS = ["Area_Director", "Secretariat", "IETF_Chair",
43+
"IAB_Chair", "IRTF_Chair", ]
44+
4245
class IetfUserBackend(RemoteUserBackend):
4346

4447
def find_groups(username):
@@ -56,6 +59,8 @@ def find_groups(username):
5659
Session_Chair chairing a non-WG session in IETF meeting
5760
Ex_Area_Director past AD
5861
"""
62+
# Any group name added by this method should be added to the
63+
# AUTOMATIC_GROUPS list
5964
groups = []
6065
try:
6166
login = IESGLogin.objects.get(login_name=username)
@@ -97,13 +102,17 @@ def authenticate(self, remote_user):
97102
profile = IetfUserProfile(user=user)
98103
profile.save()
99104

105+
# Remove any automatic groups, the proper ones will be retrieved by
106+
# find_groups
107+
groups = [group for group in user.groups.exclude(name__in=AUTOMATIC_GROUPS)]
108+
100109
# Update group memberships
101110
group_names = IetfUserBackend.find_groups(user.username)
102111
for group_name in group_names:
103112
# Create groups as needed
104113
group,created = Group.objects.get_or_create(name=group_name)
105114
if created:
106115
log("IetfUserBackend created Group '%s'" % (group_name,))
107-
user.groups.add(group)
116+
groups.append(group)
117+
user.groups = groups
108118
return user
109-

0 commit comments

Comments
 (0)