diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-20 18:19:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-20 18:19:03 +0300 |
commit | 14bd84b61276ef29b97d23642d698de769bacfd2 (patch) | |
tree | f9eba90140c1bd874211dea17750a0d422c04080 /lib/api/users.rb | |
parent | 891c388697b2db0d8ee0c8358a9bdbf6dc56d581 (diff) |
Add latest changes from gitlab-org/gitlab@15-10-stable-eev15.10.0-rc42
Diffstat (limited to 'lib/api/users.rb')
-rw-r--r-- | lib/api/users.rb | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/lib/api/users.rb b/lib/api/users.rb index cc7eb63798a..63f838c8962 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -156,7 +156,7 @@ module API entity = current_user&.can_read_all_resources? ? Entities::UserWithAdmin : Entities::UserBasic if entity == Entities::UserWithAdmin - users = users.preload(:identities, :u2f_registrations, :webauthn_registrations, :namespace, :followers, :followees, :user_preference) + users = users.preload(:identities, :webauthn_registrations, :namespace, :followers, :followees, :user_preference) end users, options = with_custom_attributes(users, { with: entity, current_user: current_user }) @@ -381,7 +381,7 @@ module API params do requires :id, type: Integer, desc: 'The ID of the user' end - patch ":id/disable_two_factor", feature_category: :authentication_and_authorization do + patch ":id/disable_two_factor", feature_category: :system_access do authenticated_as_admin! user = User.find_by_id(params[:id]) @@ -407,7 +407,7 @@ module API requires :provider, type: String, desc: 'The external provider' end # rubocop: disable CodeReuse/ActiveRecord - delete ":id/identities/:provider", feature_category: :authentication_and_authorization do + delete ":id/identities/:provider", feature_category: :system_access do authenticated_as_admin! user = User.find_by(id: params[:id]) @@ -456,7 +456,7 @@ module API desc: 'Scope of usage for the SSH key' end # rubocop: disable CodeReuse/ActiveRecord - post ":user_id/keys", feature_category: :authentication_and_authorization do + post ":user_id/keys", feature_category: :system_access do authenticated_as_admin! user = User.find_by(id: params.delete(:user_id)) @@ -479,7 +479,7 @@ module API requires :user_id, type: String, desc: 'The ID or username of the user' use :pagination end - get ':user_id/keys', requirements: API::USER_REQUIREMENTS, feature_category: :authentication_and_authorization do + get ':user_id/keys', requirements: API::USER_REQUIREMENTS, feature_category: :system_access do user = find_user(params[:user_id]) not_found!('User') unless user && can?(current_user, :read_user, user) @@ -494,7 +494,7 @@ module API requires :id, type: Integer, desc: 'The ID of the user' requires :key_id, type: Integer, desc: 'The ID of the SSH key' end - get ':id/keys/:key_id', requirements: API::USER_REQUIREMENTS, feature_category: :authentication_and_authorization do + get ':id/keys/:key_id', requirements: API::USER_REQUIREMENTS, feature_category: :system_access do user = find_user(params[:id]) not_found!('User') unless user && can?(current_user, :read_user, user) @@ -512,7 +512,7 @@ module API requires :key_id, type: Integer, desc: 'The ID of the SSH key' end # rubocop: disable CodeReuse/ActiveRecord - delete ':id/keys/:key_id', feature_category: :authentication_and_authorization do + delete ':id/keys/:key_id', feature_category: :system_access do authenticated_as_admin! user = User.find_by(id: params[:id]) @@ -537,7 +537,7 @@ module API requires :key, type: String, desc: 'The new GPG key' end # rubocop: disable CodeReuse/ActiveRecord - post ':id/gpg_keys', feature_category: :authentication_and_authorization do + post ':id/gpg_keys', feature_category: :system_access do authenticated_as_admin! user = User.find_by(id: params.delete(:id)) @@ -562,7 +562,7 @@ module API use :pagination end # rubocop: disable CodeReuse/ActiveRecord - get ':id/gpg_keys', feature_category: :authentication_and_authorization do + get ':id/gpg_keys', feature_category: :system_access do user = User.find_by(id: params[:id]) not_found!('User') unless user @@ -579,7 +579,7 @@ module API requires :key_id, type: Integer, desc: 'The ID of the GPG key' end # rubocop: disable CodeReuse/ActiveRecord - get ':id/gpg_keys/:key_id', feature_category: :authentication_and_authorization do + get ':id/gpg_keys/:key_id', feature_category: :system_access do user = User.find_by(id: params[:id]) not_found!('User') unless user @@ -598,7 +598,7 @@ module API requires :key_id, type: Integer, desc: 'The ID of the GPG key' end # rubocop: disable CodeReuse/ActiveRecord - delete ':id/gpg_keys/:key_id', feature_category: :authentication_and_authorization do + delete ':id/gpg_keys/:key_id', feature_category: :system_access do authenticated_as_admin! user = User.find_by(id: params[:id]) @@ -622,7 +622,7 @@ module API requires :key_id, type: Integer, desc: 'The ID of the GPG key' end # rubocop: disable CodeReuse/ActiveRecord - post ':id/gpg_keys/:key_id/revoke', feature_category: :authentication_and_authorization do + post ':id/gpg_keys/:key_id/revoke', feature_category: :system_access do authenticated_as_admin! user = User.find_by(id: params[:id]) @@ -726,7 +726,7 @@ module API requires :id, type: Integer, desc: 'The ID of the user' end # rubocop: disable CodeReuse/ActiveRecord - post ':id/activate', feature_category: :authentication_and_authorization do + post ':id/activate', feature_category: :system_access do authenticated_as_admin! user = User.find_by(id: params[:id]) @@ -740,7 +740,7 @@ module API params do requires :id, type: Integer, desc: 'The ID of the user' end - post ':id/approve', feature_category: :authentication_and_authorization do + post ':id/approve', feature_category: :system_access do user = User.find_by(id: params[:id]) not_found!('User') unless can?(current_user, :read_user, user) @@ -757,7 +757,7 @@ module API params do requires :id, type: Integer, desc: 'The ID of the user' end - post ':id/reject', feature_category: :authentication_and_authorization do + post ':id/reject', feature_category: :system_access do user = find_user_by_id(params) result = ::Users::RejectService.new(current_user).execute(user) @@ -775,7 +775,7 @@ module API requires :id, type: Integer, desc: 'The ID of the user' end # rubocop: disable CodeReuse/ActiveRecord - post ':id/deactivate', feature_category: :authentication_and_authorization do + post ':id/deactivate', feature_category: :system_access do authenticated_as_admin! user = User.find_by(id: params[:id]) not_found!('User') unless user @@ -801,7 +801,7 @@ module API requires :id, type: Integer, desc: 'The ID of the user' end # rubocop: disable CodeReuse/ActiveRecord - post ':id/block', feature_category: :authentication_and_authorization do + post ':id/block', feature_category: :system_access do authenticated_as_admin! user = User.find_by(id: params[:id]) not_found!('User') unless user @@ -828,7 +828,7 @@ module API requires :id, type: Integer, desc: 'The ID of the user' end # rubocop: disable CodeReuse/ActiveRecord - post ':id/unblock', feature_category: :authentication_and_authorization do + post ':id/unblock', feature_category: :system_access do authenticated_as_admin! user = User.find_by(id: params[:id]) not_found!('User') unless user @@ -848,7 +848,7 @@ module API params do requires :id, type: Integer, desc: 'The ID of the user' end - post ':id/ban', feature_category: :authentication_and_authorization do + post ':id/ban', feature_category: :system_access do authenticated_as_admin! user = find_user_by_id(params) @@ -864,7 +864,7 @@ module API params do requires :id, type: Integer, desc: 'The ID of the user' end - post ':id/unban', feature_category: :authentication_and_authorization do + post ':id/unban', feature_category: :system_access do authenticated_as_admin! user = find_user_by_id(params) @@ -928,7 +928,7 @@ module API use :pagination optional :state, type: String, default: 'all', values: %w[all active inactive], desc: 'Filters (all|active|inactive) impersonation_tokens' end - get feature_category: :authentication_and_authorization do + get feature_category: :system_access do present paginate(finder(declared_params(include_missing: false)).execute), with: Entities::ImpersonationToken end @@ -941,7 +941,7 @@ module API optional :expires_at, type: Date, desc: 'The expiration date in the format YEAR-MONTH-DAY of the impersonation token' optional :scopes, type: Array[String], coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, desc: 'The array of scopes of the impersonation token' end - post feature_category: :authentication_and_authorization do + post feature_category: :system_access do impersonation_token = finder.build(declared_params(include_missing: false)) if impersonation_token.save @@ -958,7 +958,7 @@ module API params do requires :impersonation_token_id, type: Integer, desc: 'The ID of the impersonation token' end - get ':impersonation_token_id', feature_category: :authentication_and_authorization do + get ':impersonation_token_id', feature_category: :system_access do present find_impersonation_token, with: Entities::ImpersonationToken end @@ -968,7 +968,7 @@ module API params do requires :impersonation_token_id, type: Integer, desc: 'The ID of the impersonation token' end - delete ':impersonation_token_id', feature_category: :authentication_and_authorization do + delete ':impersonation_token_id', feature_category: :system_access do token = find_impersonation_token destroy_conditionally!(token) do @@ -996,7 +996,7 @@ module API desc: 'The array of scopes of the personal access token' optional :expires_at, type: Date, desc: 'The expiration date in the format YEAR-MONTH-DAY of the personal access token' end - post feature_category: :authentication_and_authorization do + post feature_category: :system_access do response = ::PersonalAccessTokens::CreateService.new( current_user: current_user, target_user: target_user, params: declared_params(include_missing: false) ).execute @@ -1060,7 +1060,7 @@ module API params do use :pagination end - get "keys", feature_category: :authentication_and_authorization do + get "keys", feature_category: :system_access do keys = current_user.keys.preload_users present paginate(keys), with: Entities::SSHKey @@ -1073,7 +1073,7 @@ module API requires :key_id, type: Integer, desc: 'The ID of the SSH key' end # rubocop: disable CodeReuse/ActiveRecord - get "keys/:key_id", feature_category: :authentication_and_authorization do + get "keys/:key_id", feature_category: :system_access do key = current_user.keys.find_by(id: params[:key_id]) not_found!('Key') unless key @@ -1091,7 +1091,7 @@ module API optional :usage_type, type: String, values: Key.usage_types.keys, default: 'auth_and_signing', desc: 'Scope of usage for the SSH key' end - post "keys", feature_category: :authentication_and_authorization do + post "keys", feature_category: :system_access do key = ::Keys::CreateService.new(current_user, declared_params(include_missing: false)).execute if key.persisted? @@ -1108,7 +1108,7 @@ module API requires :key_id, type: Integer, desc: 'The ID of the SSH key' end # rubocop: disable CodeReuse/ActiveRecord - delete "keys/:key_id", feature_category: :authentication_and_authorization do + delete "keys/:key_id", feature_category: :system_access do key = current_user.keys.find_by(id: params[:key_id]) not_found!('Key') unless key @@ -1126,7 +1126,7 @@ module API params do use :pagination end - get 'gpg_keys', feature_category: :authentication_and_authorization do + get 'gpg_keys', feature_category: :system_access do present paginate(current_user.gpg_keys), with: Entities::GpgKey end @@ -1138,7 +1138,7 @@ module API requires :key_id, type: Integer, desc: 'The ID of the GPG key' end # rubocop: disable CodeReuse/ActiveRecord - get 'gpg_keys/:key_id', feature_category: :authentication_and_authorization do + get 'gpg_keys/:key_id', feature_category: :system_access do key = current_user.gpg_keys.find_by(id: params[:key_id]) not_found!('GPG Key') unless key @@ -1153,7 +1153,7 @@ module API params do requires :key, type: String, desc: 'The new GPG key' end - post 'gpg_keys', feature_category: :authentication_and_authorization do + post 'gpg_keys', feature_category: :system_access do key = ::GpgKeys::CreateService.new(current_user, declared_params(include_missing: false)).execute if key.persisted? @@ -1170,7 +1170,7 @@ module API requires :key_id, type: Integer, desc: 'The ID of the GPG key' end # rubocop: disable CodeReuse/ActiveRecord - post 'gpg_keys/:key_id/revoke', feature_category: :authentication_and_authorization do + post 'gpg_keys/:key_id/revoke', feature_category: :system_access do key = current_user.gpg_keys.find_by(id: params[:key_id]) not_found!('GPG Key') unless key @@ -1186,7 +1186,7 @@ module API requires :key_id, type: Integer, desc: 'The ID of the SSH key' end # rubocop: disable CodeReuse/ActiveRecord - delete 'gpg_keys/:key_id', feature_category: :authentication_and_authorization do + delete 'gpg_keys/:key_id', feature_category: :system_access do key = current_user.gpg_keys.find_by(id: params[:key_id]) not_found!('GPG Key') unless key |