Invitation codes: a link that gives an account and roles

Ported from the original (InvitationCode), adapted to configurable roles.

- Admin → Invitations: a label, optionally one email address (only it can
  use the link, and it's emailed) and a name, how many uses (or
  unlimited), an expiry (or never), and a role on any aircraft (or none,
  for an account only).
- An aircraft's Access page: whoever manages its people invites to that
  aircraft, with only the roles they can give; they see and revoke its
  invitations.
- /join/<code>: shows what it gives; create an account (when password
  sign-in is on) or sign in, then accept. Existing accounts and SSO users
  accept too. A role someone already has on an aircraft stays.
- Roles are given as the invitation's creator (AircraftAccess), and only
  while they can still manage that aircraft's people. Codes are kept as
  digests and shown once; uses are counted under a lock; account creation
  and accepting are rate-limited; any invalid link gets the same answer.
- Docs: guide (Administration, Access & sharing), README, and why /join
  isn't on the Authentik bypass list. The README's not-yet-ported list
  now names Prometheus metrics, and no longer claims oil analysis import
  as new.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-15 18:50:58 -05:00
1 parent a645778f26
commit b4c7aaa3ff
34 files changed
+822 -7

No files matched your search

+6
View File
@@ -112,6 +112,7 @@ Rails.application.routes.draw do
resource :loading_setup, path: "weight_balance/loading", only: %i[edit update] # before the records' :id routes
resources :weight_balance_records, path: "weight_balance", except: :show
resources :aircraft_roles, path: "access", only: %i[index create update destroy]
resources :invitations, controller: "aircraft_invitations", only: %i[create destroy]
resources :share_tokens, only: %i[create destroy]
resource :export, controller: "aircraft_exports", only: :show
resource :report, controller: "maintenance_reports", only: :show
@@ -131,6 +132,10 @@ Rails.application.routes.draw do
# Public read-only share links (no login).
# Invited signers (outside mechanics) sign one entry.
get "sign/:token", to: "invited_signings#show", as: :invited_signing
# Invitation codes (AccessInvitation): an account and roles on aircraft.
get "join/:token", to: "joins#show", as: :join
post "join/:token/accept", to: "joins#accept", as: :accept_join
post "join/:token/account", to: "joins#account", as: :account_join
post "sign/:token", to: "invited_signings#create"
post "sign/:token/account", to: "invited_signings#account", as: :account_invited_signing
@@ -175,6 +180,7 @@ Rails.application.routes.draw do
resources :aircraft_roles, controller: "user_aircraft_roles", only: %i[create update destroy]
end
resources :roles, except: :show
resources :invitations, only: %i[index new create destroy]
resources :integrations do
post :new_secret, on: :member
end