Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-08-08 21:10:59 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-08-08 21:10:59 +0300
commit3849f5bb99b2f46f4ffeda56b9b7ae8afe954ed3 (patch)
tree0c7e45228a4737222e57bc45ed64932056b25ac4 /app
parentbfb24e1685fb574d3144865da29a21b38cb52883 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/controllers/application_controller.rb2
-rw-r--r--app/controllers/concerns/enforces_two_factor_authentication.rb2
-rw-r--r--app/controllers/concerns/notes_actions.rb2
-rw-r--r--app/controllers/omniauth_callbacks_controller.rb18
4 files changed, 20 insertions, 4 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 8588273a41f..08e4f4956df 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -181,7 +181,7 @@ class ApplicationController < ActionController::Base
payload[:queue_duration_s] = request.env[::Gitlab::Middleware::RailsQueueDuration::GITLAB_RAILS_QUEUE_DURATION_KEY]
- payload[:response_bytes] = response.body_parts.sum(&:bytesize)
+ payload[:response_bytes] = response.body_parts.sum(&:bytesize) if Feature.enabled?(:log_response_length)
store_cloudflare_headers!(payload, request)
end
diff --git a/app/controllers/concerns/enforces_two_factor_authentication.rb b/app/controllers/concerns/enforces_two_factor_authentication.rb
index 8068913eea2..539feb3cf1c 100644
--- a/app/controllers/concerns/enforces_two_factor_authentication.rb
+++ b/app/controllers/concerns/enforces_two_factor_authentication.rb
@@ -77,7 +77,7 @@ module EnforcesTwoFactorAuthentication
end
def two_factor_verifier
- @two_factor_verifier ||= Gitlab::Auth::TwoFactorAuthVerifier.new(current_user) # rubocop:disable Gitlab/ModuleWithInstanceVariables
+ @two_factor_verifier ||= Gitlab::Auth::TwoFactorAuthVerifier.new(current_user, request) # rubocop:disable Gitlab/ModuleWithInstanceVariables
end
def mfa_help_page_url
diff --git a/app/controllers/concerns/notes_actions.rb b/app/controllers/concerns/notes_actions.rb
index 4e34094b52c..93cf1d15086 100644
--- a/app/controllers/concerns/notes_actions.rb
+++ b/app/controllers/concerns/notes_actions.rb
@@ -264,7 +264,7 @@ module NotesActions
end
def require_last_fetched_at_header!
- return if request.headers['X-Last-Fetched-At'].present? || Feature.disabled?(:require_notes_last_fetched_at)
+ return if request.headers['X-Last-Fetched-At'].present?
render json: { message: 'X-Last-Fetched-At header is required' }, status: :bad_request
end
diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb
index eda72400f17..72b3516ae3f 100644
--- a/app/controllers/omniauth_callbacks_controller.rb
+++ b/app/controllers/omniauth_callbacks_controller.rb
@@ -130,6 +130,8 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
link_identity(identity_linker)
set_remember_me(current_user)
+ store_idp_two_factor_status(build_auth_user(auth_module::User).bypass_two_factor?)
+
if identity_linker.changed?
redirect_identity_linked
elsif identity_linker.failed?
@@ -159,7 +161,9 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
end
def build_auth_user(auth_user_class)
- auth_user_class.new(oauth)
+ strong_memoize_with(:build_auth_user, auth_user_class) do
+ auth_user_class.new(oauth)
+ end
end
def sign_in_user_flow(auth_user_class)
@@ -179,12 +183,16 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
if user.two_factor_enabled? && !auth_user.bypass_two_factor?
prompt_for_two_factor(user)
+ store_idp_two_factor_status(false)
else
if user.deactivated?
user.activate
flash[:notice] = _('Welcome back! Your account had been deactivated due to inactivity but is now reactivated.')
end
+ # session variable for storing bypass two-factor request from IDP
+ store_idp_two_factor_status(true)
+
accept_pending_invitations(user: user) if new_user
persist_accepted_terms_if_required(user) if new_user
@@ -323,6 +331,14 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def sign_in_and_redirect_or_verify_identity(user, _, _)
sign_in_and_redirect(user, event: :authentication)
end
+
+ def store_idp_two_factor_status(bypass_2fa)
+ if Feature.enabled?(:by_pass_two_factor_for_current_session)
+ session[:provider_2FA] = true if bypass_2fa
+ else
+ session.delete(:provider_2FA)
+ end
+ end
end
OmniauthCallbacksController.prepend_mod_with('OmniauthCallbacksController')