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 @@
|
||||
class PasswordsController < ApplicationController
|
||||
allow_unauthenticated_access
|
||||
before_action :require_password_login
|
||||
before_action :set_user_by_token, only: %i[ edit update ]
|
||||
rate_limit to: 5, within: 15.minutes, only: :create, with: -> { redirect_to new_session_path, alert: "Try again later." }
|
||||
rate_limit to: 10, within: 15.minutes, only: :update, with: -> { redirect_to new_session_path, alert: "Try again later." }
|
||||
|
||||
def new
|
||||
end
|
||||
@@ -17,7 +20,8 @@ class PasswordsController < ApplicationController
|
||||
end
|
||||
|
||||
def update
|
||||
if @user.update(params.permit(:password, :password_confirmation))
|
||||
if params[:password].present? && @user.update(params.permit(:password, :password_confirmation))
|
||||
@user.sessions.destroy_all # a reset signs out every device
|
||||
redirect_to new_session_path, notice: "Password has been reset."
|
||||
else
|
||||
redirect_to edit_password_path(params[:token]), alert: "Passwords did not match."
|
||||
@@ -25,6 +29,10 @@ class PasswordsController < ApplicationController
|
||||
end
|
||||
|
||||
private
|
||||
def require_password_login
|
||||
redirect_to new_session_path, alert: "Sign in with #{Sso.label}." unless Sso.password_login?
|
||||
end
|
||||
|
||||
def set_user_by_token
|
||||
@user = User.find_by_password_reset_token!(params[:token])
|
||||
rescue ActiveSupport::MessageVerifier::InvalidSignature
|
||||
|
||||
Reference in new issue
Block a user