authentik icon indicating copy to clipboard operation
authentik copied to clipboard

API Bulk update for users and groups

Open boesr opened this issue 1 year ago • 1 comments

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 avatar Jul 31 '24 07:07 boesr

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.

boesr avatar Jul 31 '24 07:07 boesr