diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-10 06:14:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-10 06:14:28 +0300 |
commit | 5b225821d01b3ffd1d3c2f741c62bc0c56920a07 (patch) | |
tree | ee0064c12aae8e2a645e6b81ef6aafd926c1e306 /lib | |
parent | 0abbeedd2fe28913033e91964d355addbc8a9746 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/groups.rb | 1 | ||||
-rw-r--r-- | lib/api/helpers/rate_limiter.rb | 4 | ||||
-rw-r--r-- | lib/api/internal/base.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/application_rate_limiter.rb | 1 |
4 files changed, 12 insertions, 0 deletions
diff --git a/lib/api/groups.rb b/lib/api/groups.rb index 2efdfe109f7..1ff64cd2ffd 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -254,6 +254,7 @@ module API group = find_group!(params[:id]) group.preload_shared_group_links + mark_throttle! :update_namespace_name, scope: group if params.key?(:name) && params[:name].present? authorize! :admin_group, group group.remove_avatar! if params.key?(:avatar) && params[:avatar].nil? diff --git a/lib/api/helpers/rate_limiter.rb b/lib/api/helpers/rate_limiter.rb index be92277c25a..39940d86fbf 100644 --- a/lib/api/helpers/rate_limiter.rb +++ b/lib/api/helpers/rate_limiter.rb @@ -18,6 +18,10 @@ module API render_api_error!({ error: _('This endpoint has been requested too many times. Try again later.') }, 429) end + + def mark_throttle!(key, scope:) + Gitlab::ApplicationRateLimiter.throttled?(key, scope: scope) + end end end end diff --git a/lib/api/internal/base.rb b/lib/api/internal/base.rb index cebb1390acc..5ad058fd07d 100644 --- a/lib/api/internal/base.rb +++ b/lib/api/internal/base.rb @@ -4,12 +4,18 @@ module API # Internal access API module Internal class Base < ::API::Base + include Gitlab::RackLoadBalancingHelpers + before { authenticate_by_gitlab_shell_token! } before do api_endpoint = env['api.endpoint'] feature_category = api_endpoint.options[:for].try(:feature_category_for_app, api_endpoint).to_s + if actor.user + load_balancer_stick_request(::User, :user, actor.user.id) + end + Gitlab::ApplicationContext.push( user: -> { actor&.user }, project: -> { project }, diff --git a/lib/gitlab/application_rate_limiter.rb b/lib/gitlab/application_rate_limiter.rb index bf3f5b61825..469927b8a53 100644 --- a/lib/gitlab/application_rate_limiter.rb +++ b/lib/gitlab/application_rate_limiter.rb @@ -55,6 +55,7 @@ module Gitlab phone_verification_send_code: { threshold: 10, interval: 1.hour }, phone_verification_verify_code: { threshold: 10, interval: 10.minutes }, namespace_exists: { threshold: 20, interval: 1.minute }, + update_namespace_name: { threshold: -> { application_settings.update_namespace_name_rate_limit }, interval: 1.hour }, fetch_google_ip_list: { threshold: 10, interval: 1.minute }, project_fork_sync: { threshold: 10, interval: 30.minutes }, ai_action: { threshold: 160, interval: 8.hours }, |