diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-07-27 13:19:34 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-07-27 13:19:34 +0300 |
commit | ede8c0ced46c67a554a90829c5b65b26f0168c67 (patch) | |
tree | 24b49014ecf06254d782e0c1d6d7c82a5e056b42 /config/initializers | |
parent | 656985bf75ff2a3fd2c0f8eb88fa78847a529980 (diff) |
Catch custom warden events too to increment metrics
Diffstat (limited to 'config/initializers')
-rw-r--r-- | config/initializers/warden.rb | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/config/initializers/warden.rb b/config/initializers/warden.rb index 313604430cd..fcd52e63141 100644 --- a/config/initializers/warden.rb +++ b/config/initializers/warden.rb @@ -1,27 +1,33 @@ 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.new(env).tap do |tracker| - tracker.log_blocked_user_activity! if tracker.user_blocked? - Gitlab::Auth::Activity.new(tracker.user, opts).user_authentication_failed! + case opts[:event] + when :authentication + Gitlab::Auth::Activity.new(user, opts).user_authenticated! + when :set_user + Gitlab::Auth::Activity.new(user, opts).user_authenticated! + Gitlab::Auth::Activity.new(user, opts).user_session_override! + when :fetch + # no-op + else + Gitlab::Auth::Activity.new(user, opts).user_session_override! end end Warden::Manager.after_authentication(scope: :user) do |user, auth, opts| ActiveSession.cleanup(user) - Gitlab::Auth::Activity.new(user, opts).user_authenticated! end Warden::Manager.after_set_user(scope: :user, only: :fetch) do |user, auth, opts| ActiveSession.set(user, auth.request) end - Warden::Manager.after_set_user(scope: :user, only: :set_user) do |user, auth, opts| - Gitlab::Auth::Activity.new(user, opts).user_session_override! + 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| |