goauthentik / authentik

The authentication glue you need.
https://goauthentik.io
Other
12.63k stars 849 forks source link

API Bulk update for users and groups #10694

Open boesr opened 1 month ago

boesr commented 1 month ago

Is your feature request related to a problem? Please describe. I integrated the Authentik API in one of our tools. In one use case I need to update a attribute of all users that have a certain value of that attribute and are in a defined group. In my test scenarios these are around 1000 users. At the moment I fetch each user, update the attribute value (so I don't overwrite the complete field) and update it via the API. Authentik breaks after some updates with the error:

{"error":"context canceled","event":"failed to proxy to backend","level":"warning","logger":"authentik.router","timestamp":"2024-07-31T07:18:21Z"}

Describe the solution you'd like It would be nice to have a PUT route to update attribute values of all users / groups with a certain value for a defined attribute.

Describe alternatives you've considered I considered doing it directly within the database via a SQL query. Something like

UPDATE authentik_core_user
   set attributes['my_attribute'] = to_jsonb(15);
WHERE
  attributes->>'my_attribute' = 14

Additional context /

boesr commented 1 month ago

The above error only is thrown when I execute nearly in parallel. I adjusted to do it sequentially and now everything seems to work although it could be faster.