Notify users out-of-band when security settings change
Previously only TOTP-enabled triggered an email. Every other security-relevant change — password change, TOTP disable, passkey add/remove, API key create/revoke, email address change, backup-code regeneration — happened silently, so an attacker on a stolen session could quietly drop 2FA or hijack the email with no signal to the account holder. Add SecurityMailer with one method per event. Each email carries the request IP, user-agent, and timestamp so the user can spot unfamiliar activity. Email-address changes notify both the old and new addresses with directional language; the old-address copy explicitly warns that whoever made the change can now receive password reset emails. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,10 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
private
|
||||
|
||||
def security_event_context
|
||||
{ip: request.remote_ip, user_agent: request.user_agent, occurred_at: Time.current}
|
||||
end
|
||||
|
||||
# Remove a query parameter from a URL using proper URI parsing
|
||||
# More robust than regex - handles URL encoding, edge cases, etc.
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user