diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-08-01 01:10:35 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-08-01 01:10:35 +0200 |
| commit | f6c1f0f08f031778a491465d35ac694bfcdc12b0 (patch) | |
| tree | 99aec0f419b1122821124fdb7ae8bdf4bc5831db /lib/authenticated_test_helper.rb | |
| parent | df90138fb55f7d3652d3d69d58325d7329920f51 (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 'lib/authenticated_test_helper.rb')
| -rw-r--r-- | lib/authenticated_test_helper.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/authenticated_test_helper.rb b/lib/authenticated_test_helper.rb index 8f3a3732..065a5f7d 100644 --- a/lib/authenticated_test_helper.rb +++ b/lib/authenticated_test_helper.rb | |||
| @@ -4,4 +4,8 @@ module AuthenticatedTestHelper | |||
| 4 | @request.session[:user_id] = user ? users(user).id : nil | 4 | @request.session[:user_id] = user ? users(user).id : nil |
| 5 | @request.session[:logged_in_at] = Time.now.to_i | 5 | @request.session[:logged_in_at] = Time.now.to_i |
| 6 | end | 6 | end |
| 7 | |||
| 8 | def elevate_session! | ||
| 9 | session[:elevated_at] = Time.now.to_i | ||
| 10 | end | ||
| 7 | end | 11 | end |
