summaryrefslogtreecommitdiff
path: root/app/controllers/otp_challenges_controller.rb
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-08-01 01:10:35 +0200
committererdgeist <erdgeist@erdgeist.org>2026-08-01 01:10:35 +0200
commitf6c1f0f08f031778a491465d35ac694bfcdc12b0 (patch)
tree99aec0f419b1122821124fdb7ae8bdf4bc5831db /app/controllers/otp_challenges_controller.rb
parentdf90138fb55f7d3652d3d69d58325d7329920f51 (diff)
Require a fresh second factor for user management
Administrative actions are gated behind a 30-minute elevation window: creating and retiring accounts, editing roles, clearing a second factor. Reading the list is not gated, and content work is untouched. elevated? is tied to is_admin?, so losing the role closes the window at once. The window opens when the second factor verifies at login, so an admin heading straight for user management is already elevated, and closes on logout with the other session state. Five wrong codes end the session, mirroring the login challenge. users#update carries no elevation filter, since self-service reaches it; the role field is gated in user_params instead and fails closed.
Diffstat (limited to 'app/controllers/otp_challenges_controller.rb')
-rw-r--r--app/controllers/otp_challenges_controller.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/app/controllers/otp_challenges_controller.rb b/app/controllers/otp_challenges_controller.rb
index eeaeac20..87586241 100644
--- a/app/controllers/otp_challenges_controller.rb
+++ b/app/controllers/otp_challenges_controller.rb
@@ -28,6 +28,9 @@ class OtpChallengesController < ApplicationController
28 reset_session 28 reset_session
29 self.current_user = user 29 self.current_user = user
30 session[:logged_in_at] = Time.now.to_i 30 session[:logged_in_at] = Time.now.to_i
31 # an admin who logs in and goes straight to user management
32 # is already elevated
33 elevate! if user.is_admin?
31 flash[:notice] = t("flash.common.logged_in") 34 flash[:notice] = t("flash.common.logged_in")
32 redirect_to safe_return_to(return_to, :default => admin_path) 35 redirect_to safe_return_to(return_to, :default => admin_path)
33 else 36 else