Improve code related to the API sudo feature

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

  • Close this issue
  • The API allows admin users to impersonate any other user by using the sudo feature
  • The code for this feature is scattered across a few methods in lib/api/helpers.rb
  • Background for the creation of this issue: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/10842#note_28348788

Potential improvements

  • Rename the initial_current_user method. Currently, during a sudo call, initial_current_user points to the admin user, and current_user points to the user they are impersonating.

  • The sudo-related methods and constants in API::Helpers could be moved to a separate class/module/concern.

/cc @rymai @jamedjo

Edited Sep 26, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading