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: 7 additions & 0 deletions django_auth_adfs/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,13 @@ def update_user_groups(self, user, claim_groups):
if sorted(claim_groups) != sorted(user_group_names):
# Get the list of already existing groups in one SQL query
existing_claimed_groups = Group.objects.filter(name__in=claim_groups)
existing_claimed_group_names = (
group.name for group in existing_claimed_groups
)
Comment on lines +385 to +387
Copy link
Member

Choose a reason for hiding this comment

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

There's a redefinition of existing_claimed_group_names on line 394 that can be removed because of this.


if sorted(existing_claimed_group_names) == sorted(user_group_names):
# If the groups are already set, we don't need to do anything
return

if settings.MIRROR_GROUPS:
existing_claimed_group_names = (
Expand Down