Skip to content

Reduce SQL queries and restrict to claimed groups #377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions django_auth_adfs/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,9 @@ def update_user_groups(self, user, claim_groups):
for name in claim_groups
if name not in existing_claimed_group_names
]
# Associate the users to all claimed groups
user.groups.set(
tuple(existing_claimed_groups) + tuple(new_claimed_groups)
)
# Set user's groups to all claimed groups (both existing and
# newly created) and remove any that are not in the claim.
user.groups.set(new_claimed_groups)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding, the comment here matches the old code. The new code will set the user's groups to only the groups in the claim that didn't already have a Group instance for them.

else:
# Associate the user to only existing claimed groups
user.groups.set(existing_claimed_groups)
Expand Down
Loading