summaryrefslogtreecommitdiff
path: root/config/initializers
diff options
context:
space:
mode:
Diffstat (limited to 'config/initializers')
-rw-r--r--config/initializers/rbtrace.rb3
-rw-r--r--config/initializers/sidekiq.rb2
-rw-r--r--config/initializers/warden.rb30
3 files changed, 27 insertions, 8 deletions
diff --git a/config/initializers/rbtrace.rb b/config/initializers/rbtrace.rb
deleted file mode 100644
index 3a076c99ad0..00000000000
--- a/config/initializers/rbtrace.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-# frozen_string_literal: true
-
-require 'rbtrace' if ENV['ENABLE_RBTRACE']
diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb
index f6803eb0b5a..6f54bee4713 100644
--- a/config/initializers/sidekiq.rb
+++ b/config/initializers/sidekiq.rb
@@ -8,6 +8,8 @@ Sidekiq.default_worker_options = { retry: 3 }
enable_json_logs = Gitlab.config.sidekiq.log_format == 'json'
Sidekiq.configure_server do |config|
+ require 'rbtrace' if ENV['ENABLE_RBTRACE']
+
config.redis = queues_config_hash
config.server_middleware do |chain|
diff --git a/config/initializers/warden.rb b/config/initializers/warden.rb
index 8cc36820d3c..d64b659c6d7 100644
--- a/config/initializers/warden.rb
+++ b/config/initializers/warden.rb
@@ -1,10 +1,20 @@
Rails.application.configure do |config|
Warden::Manager.after_set_user(scope: :user) do |user, auth, opts|
Gitlab::Auth::UniqueIpsLimiter.limit_user!(user)
- end
- Warden::Manager.before_failure(scope: :user) do |env, opts|
- Gitlab::Auth::BlockedUserTracker.log_if_user_blocked(env)
+ activity = Gitlab::Auth::Activity.new(user, opts)
+
+ case opts[:event]
+ when :authentication
+ activity.user_authenticated!
+ when :set_user
+ activity.user_authenticated!
+ activity.user_session_override!
+ when :fetch # rubocop:disable Lint/EmptyWhen
+ # We ignore session fetch events
+ else
+ activity.user_session_override!
+ end
end
Warden::Manager.after_authentication(scope: :user) do |user, auth, opts|
@@ -15,7 +25,17 @@ Rails.application.configure do |config|
ActiveSession.set(user, auth.request)
end
- Warden::Manager.before_logout(scope: :user) do |user, auth, opts|
- ActiveSession.destroy(user || auth.user, auth.request.session.id)
+ Warden::Manager.before_failure(scope: :user) do |env, opts|
+ tracker = Gitlab::Auth::BlockedUserTracker.new(env)
+ tracker.log_blocked_user_activity! if tracker.user_blocked?
+
+ Gitlab::Auth::Activity.new(tracker.user, opts).user_authentication_failed!
+ end
+
+ Warden::Manager.before_logout(scope: :user) do |user_warden, auth, opts|
+ user = user_warden || auth.user
+
+ ActiveSession.destroy(user, auth.request.session.id)
+ Gitlab::Auth::Activity.new(user, opts).user_session_destroyed!
end
end