django-DefectDojo
django-DefectDojo copied to clipboard
Syncing Azure AD groups is too slow
Problem description
The performance of syncing with Microsoft Entra ID (ex. Azure AD) groups added in https://github.com/DefectDojo/django-DefectDojo/pull/6128 is unacceptably poor. It can take 20 seconds to log in a user with 45 groups.
Root cause
-
To get the names DefectDojo requests Microsoft Graph REST API v1.0 Get group endpoint (
GET /v1.0/groups/{id}) for every user’s group ID. -
DefectDojo performs O(N) queries to the database, where N is a number of the user’s groups.
Possible solution
- To reduce the number of network requests from N to 1 use the List transitive member of endpoint (
GET /v1.0/me/transitiveMemberOf). - To reduce the number of database queries from O(N) to O(1) use bulk operations like: