mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15:50:36 -05:00
- 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>
26 lines
786 B
Ruby
26 lines
786 B
Ruby
class SessionsController < ApplicationController
|
|
allow_unauthenticated_access only: %i[ new create ]
|
|
rate_limit to: 10, within: 3.minutes, only: :create, with: -> { redirect_to new_session_url, alert: "Try again later." }
|
|
|
|
def new
|
|
end
|
|
|
|
def create
|
|
return redirect_to new_session_path, alert: "Sign in with #{Sso.label}." unless Sso.password_login?
|
|
|
|
if user = User.authenticate_by(params.permit(:email_address, :password))
|
|
return_to = after_authentication_url
|
|
reset_session # fresh session id after signing in
|
|
start_new_session_for user
|
|
redirect_to return_to
|
|
else
|
|
redirect_to new_session_path, alert: "Try another email address or password."
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
terminate_session
|
|
redirect_to new_session_path
|
|
end
|
|
end
|