summaryrefslogtreecommitdiff
path: root/app/controllers/concerns
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/concerns
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/concerns')
-rw-r--r--app/controllers/concerns/role_required.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/controllers/concerns/role_required.rb b/app/controllers/concerns/role_required.rb
index b841b8cc..22ce625e 100644
--- a/app/controllers/concerns/role_required.rb
+++ b/app/controllers/concerns/role_required.rb
@@ -20,4 +20,13 @@ module RoleRequired
20 flash[:error] = t("flash.common.#{key}") 20 flash[:error] = t("flash.common.#{key}")
21 redirect_to admin_path 21 redirect_to admin_path
22 end 22 end
23
24 # require_admin must precede this in the filter chain, so a non-admin is
25 # denied by role before elevation is ever considered.
26 def require_elevation
27 return if elevated?
28
29 session[:elevation_return_to] = request.fullpath
30 redirect_to new_elevation_path
31 end
23end 32end