mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15:50:36 -05:00
Security hardening and OpenID Connect single sign-on
- SSO via OmniAuth OpenID Connect (Authentik, Keycloak, …): link by stable subject, by verified email, or from the profile; optional auto-create, admin-group sync, and turning password sign-in off - Current password required to change email or password; password changes and resets sign out other sessions; idle sessions expire after 30 days; "sign out everywhere else"; session reset on sign-in - Rate-limit password resets; scope squawk components to the aircraft - Strict Content Security Policy with nonces (inline handlers removed), Permissions-Policy and COOP headers; file links expire after an hour Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2bfcb845ca
commit
ac4da93aaf
27 files changed
+708
-47
No files matched your search
@@ -1,6 +1,9 @@
|
||||
module Authentication
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
# A session unused for this long is signed out.
|
||||
SESSION_IDLE_TIMEOUT = 30.days
|
||||
|
||||
included do
|
||||
before_action :require_authentication
|
||||
helper_method :authenticated?
|
||||
@@ -26,7 +29,15 @@ module Authentication
|
||||
end
|
||||
|
||||
def find_session_by_cookie
|
||||
Session.find_by(id: cookies.signed[:session_id]) if cookies.signed[:session_id]
|
||||
session = Session.find_by(id: cookies.signed[:session_id]) if cookies.signed[:session_id]
|
||||
return unless session
|
||||
if session.updated_at < SESSION_IDLE_TIMEOUT.ago
|
||||
session.destroy
|
||||
cookies.delete(:session_id)
|
||||
return
|
||||
end
|
||||
session.touch if session.updated_at < 1.hour.ago # last-active time, without a write per request
|
||||
session
|
||||
end
|
||||
|
||||
def request_authentication
|
||||
|
||||
Reference in new issue
Block a user