diff options
Diffstat (limited to 'lib/api/internal')
-rw-r--r-- | lib/api/internal/base.rb | 26 | ||||
-rw-r--r-- | lib/api/internal/container_registry/migration.rb | 31 | ||||
-rw-r--r-- | lib/api/internal/kubernetes.rb | 7 |
3 files changed, 44 insertions, 20 deletions
diff --git a/lib/api/internal/base.rb b/lib/api/internal/base.rb index 2ab5d482295..b53f855c3a2 100644 --- a/lib/api/internal/base.rb +++ b/lib/api/internal/base.rb @@ -43,7 +43,7 @@ module API # This is a separate method so that EE can alter its behaviour more # easily. - if Feature.enabled?(:rate_limit_gitlab_shell, default_enabled: :yaml) + if Feature.enabled?(:rate_limit_gitlab_shell) check_rate_limit!(:gitlab_shell_operation, scope: [params[:action], params[:project], actor.key_or_user]) end @@ -123,10 +123,19 @@ module API 'Could not find a user for the given key' unless actor.user end + # TODO: backwards compatibility; remove after https://gitlab.com/gitlab-org/gitlab-shell/-/merge_requests/454 is merged def two_factor_otp_check { success: false, message: 'Feature is not available' } end + def two_factor_manual_otp_check + { success: false, message: 'Feature is not available' } + end + + def two_factor_push_otp_check + { success: false, message: 'Feature is not available' } + end + def with_admin_mode_bypass!(actor_id) return yield unless Gitlab::CurrentSettings.admin_mode @@ -320,10 +329,23 @@ module API end end + # TODO: backwards compatibility; remove after https://gitlab.com/gitlab-org/gitlab-shell/-/merge_requests/454 is merged post '/two_factor_otp_check', feature_category: :authentication_and_authorization do status 200 - two_factor_otp_check + two_factor_manual_otp_check + end + + post '/two_factor_push_otp_check', feature_category: :authentication_and_authorization do + status 200 + + two_factor_push_otp_check + end + + post '/two_factor_manual_otp_check', feature_category: :authentication_and_authorization do + status 200 + + two_factor_manual_otp_check end end end diff --git a/lib/api/internal/container_registry/migration.rb b/lib/api/internal/container_registry/migration.rb index b84e14c6f31..c750db94dab 100644 --- a/lib/api/internal/container_registry/migration.rb +++ b/lib/api/internal/container_registry/migration.rb @@ -5,6 +5,7 @@ module API module ContainerRegistry class Migration < ::API::Base feature_category :container_registry + urgency :low STATUS_PRE_IMPORT_COMPLETE = 'pre_import_complete' STATUS_PRE_IMPORT_FAILED = 'pre_import_failed' @@ -36,23 +37,25 @@ module API requires :status, type: String, values: POSSIBLE_VALUES, desc: 'The migration step status' end put 'internal/registry/repositories/*repository_path/migration/status' do - repository = find_repository!(declared_params[:repository_path]) + ::Gitlab::Database::LoadBalancing::Session.current.use_primary do + repository = find_repository!(declared_params[:repository_path]) - unless repository.migration_in_active_state? - bad_request!("Wrong migration state (#{repository.migration_state})") - end - - case declared_params[:status] - when STATUS_PRE_IMPORT_COMPLETE - unless repository.finish_pre_import_and_start_import - bad_request!("Couldn't transition from pre_importing to importing") + unless repository.migration_in_active_state? + bad_request!("Wrong migration state (#{repository.migration_state})") end - when STATUS_IMPORT_COMPLETE - unless repository.finish_import - bad_request!("Couldn't transition from importing to import_done") + + case declared_params[:status] + when STATUS_PRE_IMPORT_COMPLETE + unless repository.finish_pre_import_and_start_import + bad_request!("Couldn't transition from pre_importing to importing") + end + when STATUS_IMPORT_COMPLETE + unless repository.finish_import + bad_request!("Couldn't transition from importing to import_done") + end + when STATUS_IMPORT_FAILED, STATUS_PRE_IMPORT_FAILED + repository.abort_import! end - when STATUS_IMPORT_FAILED, STATUS_PRE_IMPORT_FAILED - repository.abort_import end status 200 diff --git a/lib/api/internal/kubernetes.rb b/lib/api/internal/kubernetes.rb index 59bc917a602..34acfac4cb1 100644 --- a/lib/api/internal/kubernetes.rb +++ b/lib/api/internal/kubernetes.rb @@ -5,7 +5,6 @@ module API module Internal class Kubernetes < ::API::Base feature_category :kubernetes_management - before do check_feature_enabled authenticate_gitlab_kas_request! @@ -48,7 +47,7 @@ module API end def check_feature_enabled - not_found! unless Feature.enabled?(:kubernetes_agent_internal_api, default_enabled: true, type: :ops) + not_found! unless Feature.enabled?(:kubernetes_agent_internal_api, type: :ops) end def check_agent_token @@ -68,7 +67,7 @@ module API detail 'Retrieves agent info for the given token' end route_setting :authentication, cluster_agent_token_allowed: true - get '/agent_info' do + get '/agent_info', urgency: :low do project = agent.project status 200 @@ -82,7 +81,7 @@ module API end end - namespace 'kubernetes/agent_configuration' do + namespace 'kubernetes/agent_configuration', urgency: :low do desc 'POST agent configuration' do detail 'Store configuration for an agent' end |