-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
core: Optimize list users and groups api #18342
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for authentik-docs canceled.
|
✅ Deploy Preview for authentik-integrations canceled.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #18342 +/- ##
===========================================
- Coverage 92.98% 70.99% -21.99%
===========================================
Files 894 894
Lines 48919 48922 +3
===========================================
- Hits 45486 34732 -10754
- Misses 3433 14190 +10757
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
6499087 to
6f6904b
Compare
Signed-off-by: Marc 'risson' Schmitt <[email protected]>
✅ Deploy Preview for authentik-storybook canceled.
|
authentik/core/api/users.py
Outdated
| base_qs = base_qs.annotate( | ||
| is_superuser=Exists( | ||
| Group.objects.filter( | ||
| users=OuterRef("pk"), | ||
| is_superuser=True, | ||
| ) | ||
| ) | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can cause wrong data to be shown to the user, as the user might be superuser through an indirect membership. cc. @BeryJu
Signed-off-by: Marc 'risson' Schmitt <[email protected]>
Attempt at optimizing users and groups api for users with a lot of groups
Details
These changes reduced the response time by a factor of two or three when listing users and groups and reduced CPU load in pods and posgres. Most noticable improvement is when include_users=true or include_groups=true.
Checklist
ak test authentik/)make lint-fix)If an API change has been made
make gen-build)If changes to the frontend have been made
make web)If applicable
make docs)