mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
New accounts only from an administrator or an administrator's invitation
Anyone can add an aircraft and so manage its people, so invitations from non-administrators could bring in new accounts without an administrator. - An invitation makes a new account only if whoever made it is still an administrator when it's used; an aircraft's Access page invitations are for people who already have an account (its welcome page says so). - Signing invitations no longer make accounts: the mechanic needs one first, and the owner is told when they don't have one. - With SSO, "Continue with <provider>" on an administrator's invitation makes the account and accepts the invitation (only for its address when it has one), so invitations work without OIDC_AUTO_CREATE_USERS. That setting stays, documented as giving accounts without an invitation; the Authentik example now leaves it off. - Docs: who makes accounts (guide, README, Authentik, .env.example, API). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b4c7aaa3ff
commit
19bc3efa19
19 files changed
+159
-85
No files matched your search
+1
-1
@@ -46,7 +46,7 @@ FORCE_SSL=true
|
|||||||
# OIDC_CLIENT_ID=
|
# OIDC_CLIENT_ID=
|
||||||
# OIDC_CLIENT_SECRET=
|
# OIDC_CLIENT_SECRET=
|
||||||
# OIDC_PROVIDER_NAME=Authentik
|
# OIDC_PROVIDER_NAME=Authentik
|
||||||
# OIDC_AUTO_CREATE_USERS=false # true: create an account at first sign-in
|
# OIDC_AUTO_CREATE_USERS=false # true: an account at first sign-in for anyone the provider lets in, without an invitation
|
||||||
# OIDC_TRUST_EMAIL=false # true: link accounts by unverified email
|
# OIDC_TRUST_EMAIL=false # true: link accounts by unverified email
|
||||||
# OIDC_ADMIN_GROUP= # members become admins (synced at sign-in)
|
# OIDC_ADMIN_GROUP= # members become admins (synced at sign-in)
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ The app is a standard Rails app. Run `bin/rails db:prepare && bin/thrust bin/rai
|
|||||||
| `APP_URL` | Optional public base URL, e.g. `https://aircraft.example.com` (default `https://APP_HOST`). Used for the SSO and Google Drive redirect URIs. |
|
| `APP_URL` | Optional public base URL, e.g. `https://aircraft.example.com` (default `https://APP_HOST`). Used for the SSO and Google Drive redirect URIs. |
|
||||||
| `OIDC_ISSUER`, `OIDC_CLIENT_ID`, `OIDC_CLIENT_SECRET` | Optional. Turn on single sign-on with an OpenID Connect provider (see below). |
|
| `OIDC_ISSUER`, `OIDC_CLIENT_ID`, `OIDC_CLIENT_SECRET` | Optional. Turn on single sign-on with an OpenID Connect provider (see below). |
|
||||||
| `OIDC_PROVIDER_NAME` | Button label, e.g. `Authentik` (default `SSO`). |
|
| `OIDC_PROVIDER_NAME` | Button label, e.g. `Authentik` (default `SSO`). |
|
||||||
| `OIDC_AUTO_CREATE_USERS` | `true` creates an account for anyone the provider lets in. New accounts start with no aircraft. Default off: an admin adds users first. |
|
| `OIDC_AUTO_CREATE_USERS` | `true` creates an account for anyone the provider lets in, without an invitation. New accounts start with no aircraft. Default off: accounts come only from an admin or an admin's invitation (SSO sign-in from the invitation link makes the account). |
|
||||||
| `OIDC_TRUST_EMAIL` | `true` links existing accounts by email even if the provider doesn't mark it verified. Only use it if users can't edit their own email at the provider. |
|
| `OIDC_TRUST_EMAIL` | `true` links existing accounts by email even if the provider doesn't mark it verified. Only use it if users can't edit their own email at the provider. |
|
||||||
| `OIDC_ADMIN_GROUP` | Optional. Members of this provider group become admins and others lose admin, synced at each sign-in. |
|
| `OIDC_ADMIN_GROUP` | Optional. Members of this provider group become admins and others lose admin, synced at each sign-in. |
|
||||||
| `PWNED_PASSWORDS_CHECK` | `false` turns off the check of new passwords against Have I Been Pwned (only the first 5 characters of the password's SHA-1 are sent). Use it if the server has no outbound internet access; the check also allows the password if the service can't be reached. |
|
| `PWNED_PASSWORDS_CHECK` | `false` turns off the check of new passwords against Have I Been Pwned (only the first 5 characters of the password's SHA-1 are sent). Use it if the server has no outbound internet access; the check also allows the password if the service can't be reached. |
|
||||||
@@ -202,7 +202,7 @@ Users who aren't on an aircraft get a 404 for it, identical to a missing record.
|
|||||||
Differences from the original:
|
Differences from the original:
|
||||||
- Integer primary keys instead of UUIDs. Share tokens are 32-character random strings.
|
- Integer primary keys instead of UUIDs. Share tokens are 32-character random strings.
|
||||||
- Logbook entries and inspection records don't keep many-to-many links to components. An inspection record or AD compliance can reference one component.
|
- Logbook entries and inspection records don't keep many-to-many links to components. An inspection record or AD compliance can reference one component.
|
||||||
- Accounts are created by an admin, by the first-run setup, at first SSO sign-in (if `OIDC_AUTO_CREATE_USERS` is on), by an outside mechanic accepting a signing invitation, or by someone opening an invitation link (Admin → Invitations, or an aircraft's Access page).
|
- Accounts are created only by an admin, by the first-run setup, by someone opening an admin's invitation link (with a password, or SSO), or at first SSO sign-in when `OIDC_AUTO_CREATE_USERS` is on. Invitations from an aircraft's Access page and signing invitations are for existing accounts.
|
||||||
|
|
||||||
### Not yet ported
|
### Not yet ported
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
# The invited signer's side: sign in (or create an account for the invited
|
# The invited signer's side: sign in with their account for the invited
|
||||||
# address), add a certificate if needed, review the entry and sign it. The
|
# address, add a certificate if needed, review the entry and sign it. The
|
||||||
# invitation gives access to that one entry only.
|
# invitation gives access to that one entry only. It doesn't make accounts:
|
||||||
|
# only an administrator (or an administrator's invitation) does.
|
||||||
class InvitedSigningsController < ApplicationController
|
class InvitedSigningsController < ApplicationController
|
||||||
include EntrySigning
|
include EntrySigning
|
||||||
allow_unauthenticated_access only: %i[show account]
|
allow_unauthenticated_access only: :show
|
||||||
before_action :set_invitation
|
before_action :set_invitation
|
||||||
rate_limit to: 10, within: 15.minutes, only: :account, with: -> { redirect_to new_session_path, alert: t("flash.invited_signings.try_again_later") }
|
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@entry = @invitation.logbook_entry
|
@entry = @invitation.logbook_entry
|
||||||
@@ -20,24 +20,6 @@ class InvitedSigningsController < ApplicationController
|
|||||||
render :new
|
render :new
|
||||||
end
|
end
|
||||||
|
|
||||||
# Creating an account for the invited email address.
|
|
||||||
def account
|
|
||||||
return redirect_to(invited_signing_path(params[:token])) if authenticated?
|
|
||||||
if User.exists?(email_address: @invitation.email) || !Sso.password_login?
|
|
||||||
return redirect_to invited_signing_path(params[:token]), alert: t("flash.invited_signings.sign_in_to_continue")
|
|
||||||
end
|
|
||||||
user = User.new(params.permit(:name, :password, :password_confirmation).merge(email_address: @invitation.email))
|
|
||||||
if user.save
|
|
||||||
reset_session
|
|
||||||
start_new_session_for user
|
|
||||||
redirect_to invited_signing_path(params[:token]), notice: t("flash.invited_signings.account_created_add_your")
|
|
||||||
else
|
|
||||||
@entry = @invitation.logbook_entry
|
|
||||||
@account_errors = user.errors.full_messages
|
|
||||||
render :welcome, status: :unprocessable_entity
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@entry = @invitation.logbook_entry
|
@entry = @invitation.logbook_entry
|
||||||
@aircraft = @entry.aircraft
|
@aircraft = @entry.aircraft
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
# Opening an invitation link (AccessInvitation): see what it gives, then
|
# Opening an invitation link (AccessInvitation): see what it gives, then sign
|
||||||
# create an account (when sign-in by password is on) or sign in, and accept.
|
# in and accept. Only an administrator's invitation can make a new account
|
||||||
# An invitation for one email address only works for that address. An
|
# (with a password here, or by signing in with SSO: SsoController); others
|
||||||
# invalid link (unknown, expired, used up, revoked) gets one answer for all.
|
# need an existing one. An invitation for one email address only works for
|
||||||
|
# that address. Any invalid link (unknown, expired, used up, revoked) gets
|
||||||
|
# one answer.
|
||||||
class JoinsController < ApplicationController
|
class JoinsController < ApplicationController
|
||||||
allow_unauthenticated_access only: %i[show account]
|
allow_unauthenticated_access only: %i[show account]
|
||||||
before_action :set_invitation
|
before_action :set_invitation
|
||||||
@@ -11,6 +13,7 @@ class JoinsController < ApplicationController
|
|||||||
def show
|
def show
|
||||||
unless current_user
|
unless current_user
|
||||||
session[:return_to_after_authenticating] = request.url
|
session[:return_to_after_authenticating] = request.url
|
||||||
|
session[:join_token] = params[:token] # for an account made by signing in with SSO
|
||||||
return render(:welcome)
|
return render(:welcome)
|
||||||
end
|
end
|
||||||
return redirect_to(root_path, notice: t("flash.joins.already_accepted")) if @invitation.redeemed_by?(current_user)
|
return redirect_to(root_path, notice: t("flash.joins.already_accepted")) if @invitation.redeemed_by?(current_user)
|
||||||
@@ -21,7 +24,9 @@ class JoinsController < ApplicationController
|
|||||||
# A new account, then the invitation accepted with it.
|
# A new account, then the invitation accepted with it.
|
||||||
def account
|
def account
|
||||||
return redirect_to(join_path(params[:token])) if current_user
|
return redirect_to(join_path(params[:token])) if current_user
|
||||||
return redirect_to(join_path(params[:token]), alert: t("flash.joins.sign_in_to_continue")) unless Sso.password_login?
|
unless Sso.password_login? && @invitation.creates_accounts?
|
||||||
|
return redirect_to(join_path(params[:token]), alert: t("flash.joins.sign_in_to_continue"))
|
||||||
|
end
|
||||||
email = @invitation.email || params[:email_address].to_s.strip.downcase
|
email = @invitation.email || params[:email_address].to_s.strip.downcase
|
||||||
if User.exists?(email_address: email)
|
if User.exists?(email_address: email)
|
||||||
return redirect_to join_path(params[:token]), alert: t("flash.joins.account_exists")
|
return redirect_to join_path(params[:token]), alert: t("flash.joins.account_exists")
|
||||||
@@ -35,7 +40,7 @@ class JoinsController < ApplicationController
|
|||||||
if results
|
if results
|
||||||
reset_session
|
reset_session
|
||||||
start_new_session_for user
|
start_new_session_for user
|
||||||
redirect_to root_path, notice: summary(results, t("flash.joins.welcome"))
|
redirect_to root_path, notice: [ t("flash.joins.welcome"), AccessInvitation.describe(results) ].join(" ").strip
|
||||||
else
|
else
|
||||||
@account_errors = user.errors.full_messages
|
@account_errors = user.errors.full_messages
|
||||||
render :welcome, status: :unprocessable_entity
|
render :welcome, status: :unprocessable_entity
|
||||||
@@ -47,7 +52,7 @@ class JoinsController < ApplicationController
|
|||||||
def accept
|
def accept
|
||||||
return redirect_to(root_path, notice: t("flash.joins.already_accepted")) if @invitation.redeemed_by?(current_user)
|
return redirect_to(root_path, notice: t("flash.joins.already_accepted")) if @invitation.redeemed_by?(current_user)
|
||||||
return render(:wrong_account) unless @invitation.for?(current_user)
|
return render(:wrong_account) unless @invitation.for?(current_user)
|
||||||
redirect_to root_path, notice: summary(@invitation.redeem!(current_user), t("flash.joins.accepted"))
|
redirect_to root_path, notice: [ t("flash.joins.accepted"), AccessInvitation.describe(@invitation.redeem!(current_user)) ].join(" ").strip
|
||||||
rescue ActiveRecord::RecordInvalid
|
rescue ActiveRecord::RecordInvalid
|
||||||
render :invalid, layout: "public", status: :not_found
|
render :invalid, layout: "public", status: :not_found
|
||||||
end
|
end
|
||||||
@@ -59,13 +64,5 @@ class JoinsController < ApplicationController
|
|||||||
render :invalid, layout: "public", status: :not_found unless @invitation&.usable?
|
render :invalid, layout: "public", status: :not_found unless @invitation&.usable?
|
||||||
end
|
end
|
||||||
|
|
||||||
# "Invitation accepted. N12345: Mechanic. N54321: already Owner, unchanged."
|
|
||||||
def summary(results, lead)
|
|
||||||
parts = results.map do |aircraft, role, message|
|
|
||||||
"#{aircraft.tail_number}: #{[ role&.name, message ].compact.join(', ')}"
|
|
||||||
end
|
|
||||||
[ lead, *parts ].join(" ")
|
|
||||||
end
|
|
||||||
|
|
||||||
def current_user = Current.user || (resume_session && Current.user)
|
def current_user = Current.user || (resume_session && Current.user)
|
||||||
end
|
end
|
||||||
@@ -22,7 +22,9 @@ class SigningInvitationsController < ApplicationController
|
|||||||
tail: @aircraft.tail_number, name: current_user.display_name)
|
tail: @aircraft.tail_number, name: current_user.display_name)
|
||||||
end
|
end
|
||||||
log_event("logbook", t("flash.signing_invitations.signature_requested_from_entry", email: @invitation.email, date: l(@entry.date, format: :app)))
|
log_event("logbook", t("flash.signing_invitations.signature_requested_from_entry", email: @invitation.email, date: l(@entry.date, format: :app)))
|
||||||
redirect_to aircraft_logbook_entry_path(@aircraft, @entry), notice: t("flash.signing_invitations.invitation_sent_to_the", email: @invitation.email, days: SigningInvitation::VALID_FOR.in_days.to_i)
|
notice = t("flash.signing_invitations.invitation_sent_to_the", email: @invitation.email, days: SigningInvitation::VALID_FOR.in_days.to_i)
|
||||||
|
notice = "#{notice} #{t('flash.signing_invitations.no_account_yet')}" unless invitee
|
||||||
|
redirect_to aircraft_logbook_entry_path(@aircraft, @entry), notice: notice
|
||||||
else
|
else
|
||||||
render :new, status: :unprocessable_entity
|
render :new, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
# email is verified (or OIDC_TRUST_EMAIL is on), since some providers let
|
# email is verified (or OIDC_TRUST_EMAIL is on), since some providers let
|
||||||
# users edit their email. Otherwise, sign in with a password once and link
|
# users edit their email. Otherwise, sign in with a password once and link
|
||||||
# from the profile page.
|
# from the profile page.
|
||||||
|
#
|
||||||
|
# Someone without an account gets one only from an administrator's
|
||||||
|
# invitation they opened first (AccessInvitation, accepted at once), or for
|
||||||
|
# anyone the provider lets in when OIDC_AUTO_CREATE_USERS is on.
|
||||||
class SsoController < ApplicationController
|
class SsoController < ApplicationController
|
||||||
allow_unauthenticated_access only: %i[callback failure]
|
allow_unauthenticated_access only: %i[callback failure]
|
||||||
before_action :require_sso
|
before_action :require_sso
|
||||||
@@ -29,6 +33,7 @@ class SsoController < ApplicationController
|
|||||||
return_to = session[:return_to_after_authenticating]
|
return_to = session[:return_to_after_authenticating]
|
||||||
reset_session # fresh session id after signing in
|
reset_session # fresh session id after signing in
|
||||||
start_new_session_for user
|
start_new_session_for user
|
||||||
|
return redirect_to(root_url, notice: [ t("flash.joins.welcome"), AccessInvitation.describe(@joined) ].join(" ").strip) if @joined
|
||||||
redirect_to return_to || root_url
|
redirect_to return_to || root_url
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -81,15 +86,27 @@ class SsoController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_user(auth)
|
def create_user(auth)
|
||||||
return unless Sso.auto_create_users?
|
|
||||||
email = auth.info&.email.to_s.strip.downcase
|
email = auth.info&.email.to_s.strip.downcase
|
||||||
return if email.blank? || User.exists?(email_address: email)
|
return if email.blank? || User.exists?(email_address: email)
|
||||||
# The random password is never shown; a password reset can set a real one.
|
invitation = invitation_making_account(email)
|
||||||
User.create!(email_address: email, name: auth.info&.name.presence, sso_uid: auth.uid, password: SecureRandom.base58(40))
|
return unless invitation || Sso.auto_create_users?
|
||||||
|
User.transaction do
|
||||||
|
# The random password is never shown; a password reset can set a real one.
|
||||||
|
user = User.create!(email_address: email, name: auth.info&.name.presence, sso_uid: auth.uid, password: SecureRandom.base58(40))
|
||||||
|
@joined = invitation&.redeem!(user)
|
||||||
|
user
|
||||||
|
end
|
||||||
rescue ActiveRecord::RecordInvalid
|
rescue ActiveRecord::RecordInvalid
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# The invitation opened in this browser before signing in, when it can
|
||||||
|
# make an account (an administrator's) for this email address.
|
||||||
|
def invitation_making_account(email)
|
||||||
|
invitation = AccessInvitation.find_by_token(session[:join_token])
|
||||||
|
invitation if invitation&.usable? && invitation.creates_accounts? && invitation.for_email?(email)
|
||||||
|
end
|
||||||
|
|
||||||
def email_verified?(auth)
|
def email_verified?(auth)
|
||||||
[ true, "true" ].include?(raw_info(auth)["email_verified"])
|
[ true, "true" ].include?(raw_info(auth)["email_verified"])
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,6 +4,10 @@
|
|||||||
# people (its Access page, that aircraft). Limited by number of uses, an
|
# people (its Access page, that aircraft). Limited by number of uses, an
|
||||||
# expiry, and optionally to one email address; it can be revoked. Only a
|
# expiry, and optionally to one email address; it can be revoked. Only a
|
||||||
# digest of the code is kept, so the link is shown once, when it's made.
|
# digest of the code is kept, so the link is shown once, when it's made.
|
||||||
|
#
|
||||||
|
# New accounts are only ever made by an administrator or from an
|
||||||
|
# administrator's invitation: anyone can add an aircraft and so manage its
|
||||||
|
# people, so other invitations are for people who already have an account.
|
||||||
class AccessInvitation < ApplicationRecord
|
class AccessInvitation < ApplicationRecord
|
||||||
VALID_FOR = 14.days
|
VALID_FOR = 14.days
|
||||||
|
|
||||||
@@ -40,14 +44,23 @@ class AccessInvitation < ApplicationRecord
|
|||||||
invitation
|
invitation
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# "N12345: Mechanic. N54321: already Owner, unchanged" (from #redeem!).
|
||||||
|
def self.describe(results)
|
||||||
|
results.map { |aircraft, role, message| "#{aircraft.tail_number}: #{[ role&.name, message ].compact.join(', ')}" }.join(" ")
|
||||||
|
end
|
||||||
|
|
||||||
def self.digest(token) = OpenSSL::Digest::SHA256.hexdigest(token.to_s)
|
def self.digest(token) = OpenSSL::Digest::SHA256.hexdigest(token.to_s)
|
||||||
def self.find_by_token(token) = token.present? ? find_by(token_digest: digest(token)) : nil
|
def self.find_by_token(token) = token.present? ? find_by(token_digest: digest(token)) : nil
|
||||||
|
|
||||||
def usable? = !revoked? && !expired? && !used_up?
|
def usable? = !revoked? && !expired? && !used_up?
|
||||||
|
# Whether someone without an account can make one with it (see above),
|
||||||
|
# decided when it's used: its creator must still be an administrator.
|
||||||
|
def creates_accounts? = created_by.present? && created_by.admin? && !created_by.disabled?
|
||||||
|
def for_email?(email) = self.email.nil? || self.email == email.to_s.strip.downcase
|
||||||
def revoked? = revoked_at.present?
|
def revoked? = revoked_at.present?
|
||||||
def expired? = expires_at.present? && expires_at <= Time.current
|
def expired? = expires_at.present? && expires_at <= Time.current
|
||||||
def used_up? = max_uses.present? && uses_count >= max_uses
|
def used_up? = max_uses.present? && uses_count >= max_uses
|
||||||
def for?(user) = email.nil? || email == user.email_address
|
def for?(user) = for_email?(user.email_address)
|
||||||
def redeemed_by?(user) = redemptions.exists?(user: user)
|
def redeemed_by?(user) = redemptions.exists?(user: user)
|
||||||
|
|
||||||
# Gives the person the invitation's roles, as if its creator added them
|
# Gives the person the invitation's roles, as if its creator added them
|
||||||
|
|||||||
@@ -5,15 +5,7 @@
|
|||||||
<div class="card card-body space-y-3">
|
<div class="card card-body space-y-3">
|
||||||
<%= link_to t(".i_have_an_account_sign"), new_session_path, class: "btn-primary w-full justify-center" %>
|
<%= link_to t(".i_have_an_account_sign"), new_session_path, class: "btn-primary w-full justify-center" %>
|
||||||
</div>
|
</div>
|
||||||
<% if Sso.password_login? && !User.exists?(email_address: @invitation.email) %>
|
<% unless User.exists?(email_address: @invitation.email) %>
|
||||||
<%= form_with url: account_invited_signing_path(params[:token]), class: "card card-body space-y-3" do %>
|
<p class="text-sm text-slate-600"><%= t(".no_account_yet", email: @invitation.email) %></p>
|
||||||
<h2 class="card-title"><%= t(".or_create_an_account") %></h2>
|
|
||||||
<% if @account_errors.present? %><div class="rounded-md bg-red-50 p-2 text-sm text-red-700"><%= @account_errors.to_sentence %></div><% end %>
|
|
||||||
<div><label class="label"><%= t(".email") %></label><input class="input" value="<%= @invitation.email %>" disabled></div>
|
|
||||||
<div><%= label_tag :name, t(".your_name"), class: "label" %><%= text_field_tag :name, params[:name], class: "input", required: true %></div>
|
|
||||||
<div><%= label_tag :password, t(".password"), class: "label" %><%= password_field_tag :password, nil, class: "input", required: true, autocomplete: "new-password", minlength: User::PASSWORD_MIN, maxlength: 72 %><p class="hint"><%= t(".at_least_characters_not_one_html", min: (User::PASSWORD_MIN)) %></p></div>
|
|
||||||
<div><%= label_tag :password_confirmation, t(".confirm_password"), class: "label" %><%= password_field_tag :password_confirmation, nil, class: "input", required: true, autocomplete: "new-password" %></div>
|
|
||||||
<%= submit_tag t(".create_account"), class: "btn-secondary" %>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
@@ -6,10 +6,15 @@
|
|||||||
<%= render "joins/grants", invitation: @invitation %>
|
<%= render "joins/grants", invitation: @invitation %>
|
||||||
</div>
|
</div>
|
||||||
<div class="card card-body space-y-3">
|
<div class="card card-body space-y-3">
|
||||||
<%= link_to t(".i_have_an_account"), new_session_path, class: "btn-primary w-full justify-center" %>
|
<% if Sso.enabled? && @invitation.creates_accounts? %>
|
||||||
|
<%= button_to t(".continue_with", provider: Sso.label), "/auth/#{Sso::PROVIDER}", class: "btn-primary w-full justify-center", data: { turbo: false } %>
|
||||||
|
<p class="hint"><%= t(".sso_hint", provider: Sso.label) %></p>
|
||||||
|
<% end %>
|
||||||
|
<%= link_to t(".i_have_an_account"), new_session_path, class: [ "w-full justify-center", (Sso.enabled? && @invitation.creates_accounts? ? "btn-secondary" : "btn-primary") ] %>
|
||||||
<% if @invitation.email %><p class="hint"><%= t(".for_email", email: @invitation.email) %></p><% end %>
|
<% if @invitation.email %><p class="hint"><%= t(".for_email", email: @invitation.email) %></p><% end %>
|
||||||
|
<% unless @invitation.creates_accounts? %><p class="hint"><%= t(".existing_accounts_only") %></p><% end %>
|
||||||
</div>
|
</div>
|
||||||
<% if Sso.password_login? && !(@invitation.email && User.exists?(email_address: @invitation.email)) %>
|
<% if @invitation.creates_accounts? && Sso.password_login? && !(@invitation.email && User.exists?(email_address: @invitation.email)) %>
|
||||||
<%= form_with url: account_join_path(params[:token]), class: "card card-body space-y-3" do %>
|
<%= form_with url: account_join_path(params[:token]), class: "card card-body space-y-3" do %>
|
||||||
<h2 class="card-title"><%= t(".or_create_an_account") %></h2>
|
<h2 class="card-title"><%= t(".or_create_an_account") %></h2>
|
||||||
<% if @account_errors.present? %><div class="rounded-md bg-red-50 p-2 text-sm text-red-700" role="alert"><%= @account_errors.to_sentence %></div><% end %>
|
<% if @account_errors.present? %><div class="rounded-md bg-red-50 p-2 text-sm text-red-700" role="alert"><%= @account_errors.to_sentence %></div><% end %>
|
||||||
|
|||||||
+11
-16
@@ -869,9 +869,6 @@ en:
|
|||||||
wrong_code: That setup code isn't right. It's in the server's log, on the line starting "Setup code".
|
wrong_code: That setup code isn't right. It's in the server's log, on the line starting "Setup code".
|
||||||
try_again_later: Too many tries. Wait a few minutes and try again.
|
try_again_later: Too many tries. Wait a few minutes and try again.
|
||||||
invited_signings:
|
invited_signings:
|
||||||
try_again_later: Try again later.
|
|
||||||
sign_in_to_continue: Sign in to continue.
|
|
||||||
account_created_add_your: Account created. Add your certificate, then sign.
|
|
||||||
signed: Signed. %{label} %{signer_name}, %{certificate_label} %{certificate_number}.
|
signed: Signed. %{label} %{signer_name}, %{certificate_label} %{certificate_number}.
|
||||||
flight_imports:
|
flight_imports:
|
||||||
imported_flights:
|
imported_flights:
|
||||||
@@ -1027,6 +1024,7 @@ en:
|
|||||||
this_entry_is_already: This entry is already signed.
|
this_entry_is_already: This entry is already signed.
|
||||||
email_isn_t_set: Email isn't set up, so invitations can't be sent (Admin → About).
|
email_isn_t_set: Email isn't set up, so invitations can't be sent (Admin → About).
|
||||||
invitation_sent_to_the: Invitation sent to %{email}. The link works once, for %{days} days.
|
invitation_sent_to_the: Invitation sent to %{email}. The link works once, for %{days} days.
|
||||||
|
no_account_yet: They don't have an account here yet; ask the administrator to add them (or invite them) so they can sign.
|
||||||
signature_requested_from_entry: Signature requested from %{email} (%{date} entry)
|
signature_requested_from_entry: Signature requested from %{email} (%{date} entry)
|
||||||
standard_inspections:
|
standard_inspections:
|
||||||
added_record_when_each: Added %{items}. Record when each was last done to see when it's next due.
|
added_record_when_each: Added %{items}. Record when each was last done to see when it's next due.
|
||||||
@@ -1245,7 +1243,7 @@ en:
|
|||||||
index:
|
index:
|
||||||
invitations: Invitations
|
invitations: Invitations
|
||||||
new_invitation: New invitation
|
new_invitation: New invitation
|
||||||
intro: An invitation is a link someone opens to create an account, or accept with the one they have, and get roles on aircraft. An aircraft's Owner can also invite people to that aircraft from its Access page.
|
intro: An invitation is a link someone opens to create an account, or accept with the one they have, and get roles on aircraft. New accounts come only from administrators and their invitations; an aircraft's Owner can invite people who already have an account from its Access page.
|
||||||
label: Invitation
|
label: Invitation
|
||||||
gives: Gives
|
gives: Gives
|
||||||
uses: Used
|
uses: Used
|
||||||
@@ -1966,7 +1964,7 @@ en:
|
|||||||
optional: Optional
|
optional: Optional
|
||||||
max_uses: Uses
|
max_uses: Uses
|
||||||
expires: Expires
|
expires: Expires
|
||||||
invitation_hint: A link that gives the role on this aircraft to whoever opens it, with a new or existing account. With an email, it only works for that address (and is emailed to it when email is set up). Leave the expiry empty for never, or the uses empty for unlimited.
|
invitation_hint: A link that gives the role on this aircraft to whoever opens it and signs in. It's for people who already have an account (only the administrator makes new ones). With an email, it only works for that address (and is emailed to it when email is set up). Leave the expiry empty for never, or the uses empty for unlimited.
|
||||||
create_invitation: Create invitation
|
create_invitation: Create invitation
|
||||||
roles_are_set_by_an_administrator: An administrator sets what each role can do, and can add roles (Admin → Roles). Only an Owner can give or take away the Owner role.
|
roles_are_set_by_an_administrator: An administrator sets what each role can do, and can add roles (Admin → Roles). Only an Owner can give or take away the Owner role.
|
||||||
share_links: Share Links
|
share_links: Share Links
|
||||||
@@ -2701,13 +2699,7 @@ en:
|
|||||||
sign_a_logbook_entry: Sign a logbook entry
|
sign_a_logbook_entry: Sign a logbook entry
|
||||||
you_ve_been_asked_to_html: You've been asked to sign the %{date} %{log_type} log entry for %{tail_number}. First, sign in as <strong>%{email}</strong>.
|
you_ve_been_asked_to_html: You've been asked to sign the %{date} %{log_type} log entry for %{tail_number}. First, sign in as <strong>%{email}</strong>.
|
||||||
i_have_an_account_sign: 'I have an account: sign in'
|
i_have_an_account_sign: 'I have an account: sign in'
|
||||||
or_create_an_account: Or create an account
|
no_account_yet: There's no account for %{email} yet. Ask the aircraft's owner to have the administrator add you (or invite you), then open this link again.
|
||||||
email: Email
|
|
||||||
at_least_characters_not_one_html: At least %{min} characters; not one known from a data breach.
|
|
||||||
create_account: Create account
|
|
||||||
confirm_password: Confirm password
|
|
||||||
your_name: Your name
|
|
||||||
password: Password
|
|
||||||
wrong_account:
|
wrong_account:
|
||||||
sign_a_logbook_entry: Sign a logbook entry
|
sign_a_logbook_entry: Sign a logbook entry
|
||||||
wrong_account: Wrong account
|
wrong_account: Wrong account
|
||||||
@@ -3497,6 +3489,9 @@ en:
|
|||||||
invited_by_html: "<strong>%{who}</strong> invites you (%{label}):"
|
invited_by_html: "<strong>%{who}</strong> invites you (%{label}):"
|
||||||
an_administrator: An administrator
|
an_administrator: An administrator
|
||||||
i_have_an_account: I have an account – sign in
|
i_have_an_account: I have an account – sign in
|
||||||
|
continue_with: Continue with %{provider}
|
||||||
|
sso_hint: Signs you in with %{provider}, making your account here if you don't have one yet.
|
||||||
|
existing_accounts_only: This invitation is for an existing account. If you don't have one, ask the administrator.
|
||||||
for_email: This invitation is for %{email}.
|
for_email: This invitation is for %{email}.
|
||||||
or_create_an_account: Or create an account
|
or_create_an_account: Or create an account
|
||||||
email: Email
|
email: Email
|
||||||
@@ -3517,7 +3512,7 @@ en:
|
|||||||
wrong_account:
|
wrong_account:
|
||||||
invitation: Invitation
|
invitation: Invitation
|
||||||
wrong_account: This invitation is for someone else
|
wrong_account: This invitation is for someone else
|
||||||
for_another_email_html: It's for <strong>%{email}</strong>, but you're signed in as %{email_address}. Sign out and sign in (or create an account) with that address.
|
for_another_email_html: It's for <strong>%{email}</strong>, but you're signed in as %{email_address}. Sign out and sign in with that address.
|
||||||
sign_out: Sign out
|
sign_out: Sign out
|
||||||
invalid:
|
invalid:
|
||||||
invitation: Invitation
|
invitation: Invitation
|
||||||
@@ -3528,18 +3523,18 @@ en:
|
|||||||
asks_you_to_sign_a_html: "%{owner} asks you to sign a logbook entry for <strong>%{tail_number}</strong> (%{date}, %{log_type} log)."
|
asks_you_to_sign_a_html: "%{owner} asks you to sign a logbook entry for <strong>%{tail_number}</strong> (%{date}, %{log_type} log)."
|
||||||
review_and_sign_the_entry: Review and sign the entry
|
review_and_sign_the_entry: Review and sign the entry
|
||||||
the_link_works_once_until_html: "%{link} (the link works once, until %{to_date})."
|
the_link_works_once_until_html: "%{link} (the link works once, until %{to_date})."
|
||||||
you_ll_sign_in_or_html: You'll sign in or create an account for %{email}, add your certificate, and sign with your password.
|
you_ll_sign_in_or_html: You'll sign in with your account for %{email} (if you don't have one, ask the owner to have the administrator add you first), add your certificate, and sign with your password.
|
||||||
asks_you_to_sign_a_2_html: "%{owner} asks you to sign a logbook entry for %{tail_number} (%{date}, %{log_type} log)."
|
asks_you_to_sign_a_2_html: "%{owner} asks you to sign a logbook entry for %{tail_number} (%{date}, %{log_type} log)."
|
||||||
review_and_sign_it_here_html: 'Review and sign it here (the link works once, until %{to_date}):'
|
review_and_sign_it_here_html: 'Review and sign it here (the link works once, until %{to_date}):'
|
||||||
asks_you_to_sign_a_2_text: "%{owner} asks you to sign a logbook entry for %{tail_number} (%{date}, %{log_type} log)."
|
asks_you_to_sign_a_2_text: "%{owner} asks you to sign a logbook entry for %{tail_number} (%{date}, %{log_type} log)."
|
||||||
review_and_sign_it_here_text: 'Review and sign it here (the link works once, until %{to_date}):'
|
review_and_sign_it_here_text: 'Review and sign it here (the link works once, until %{to_date}):'
|
||||||
you_ll_sign_in_or_text: You'll sign in or create an account for %{email}, add your certificate, and sign with your password.
|
you_ll_sign_in_or_text: You'll sign in with your account for %{email} (if you don't have one, ask the owner to have the administrator add you first), add your certificate, and sign with your password.
|
||||||
the_owner: The owner
|
the_owner: The owner
|
||||||
subject: Please sign a logbook entry for %{tail_number}
|
subject: Please sign a logbook entry for %{tail_number}
|
||||||
signing_invitations:
|
signing_invitations:
|
||||||
new:
|
new:
|
||||||
ask_someone_to_sign: Ask someone to sign
|
ask_someone_to_sign: Ask someone to sign
|
||||||
for_a_mechanic_who_did: 'For a mechanic who did the work: they get a one-time link by email, sign in or create their own account, add their certificate, and sign this entry with their own password. They see only this entry.'
|
for_a_mechanic_who_did: 'For a mechanic who did the work: they get a one-time link by email, sign in with their own account, add their certificate, and sign this entry with their own password. They see only this entry. They need an account first: the administrator adds it, or invites them.'
|
||||||
log_html: "%{date} · %{log_type} log · %{truncate}"
|
log_html: "%{date} · %{log_type} log · %{truncate}"
|
||||||
their_email: Their email
|
their_email: Their email
|
||||||
message_optional: Message (optional)
|
message_optional: Message (optional)
|
||||||
|
|||||||
@@ -137,7 +137,6 @@ Rails.application.routes.draw do
|
|||||||
post "join/:token/accept", to: "joins#accept", as: :accept_join
|
post "join/:token/accept", to: "joins#accept", as: :accept_join
|
||||||
post "join/:token/account", to: "joins#account", as: :account_join
|
post "join/:token/account", to: "joins#account", as: :account_join
|
||||||
post "sign/:token", to: "invited_signings#create"
|
post "sign/:token", to: "invited_signings#create"
|
||||||
post "sign/:token/account", to: "invited_signings#account", as: :account_invited_signing
|
|
||||||
|
|
||||||
# Calendar feed of what's coming due (secret link; calendar apps can't sign in).
|
# Calendar feed of what's coming due (secret link; calendar apps can't sign in).
|
||||||
get "calendar/:token.ics", to: "calendar_feeds#show", as: :calendar_feed, constraints: { token: /[A-Za-z0-9]{32}/ },
|
get "calendar/:token.ics", to: "calendar_feeds#show", as: :calendar_feed, constraints: { token: /[A-Za-z0-9]{32}/ },
|
||||||
|
|||||||
+6
-4
@@ -29,7 +29,7 @@ OIDC_CLIENT_SECRET=...
|
|||||||
OIDC_PROVIDER_NAME=Authentik
|
OIDC_PROVIDER_NAME=Authentik
|
||||||
# Optional:
|
# Optional:
|
||||||
OIDC_ADMIN_GROUP=aircraft-admins # members become app admins; others lose admin at sign-in
|
OIDC_ADMIN_GROUP=aircraft-admins # members become app admins; others lose admin at sign-in
|
||||||
OIDC_AUTO_CREATE_USERS=true # create an account at first sign-in (new accounts have no aircraft)
|
OIDC_AUTO_CREATE_USERS=false # true: an account for anyone Authentik lets in, without an invitation
|
||||||
```
|
```
|
||||||
|
|
||||||
Restart the app. The first SSO sign-in links an existing account with the same email if Authentik marks the email verified. Otherwise sign in with the password and use **Profile → Link Authentik**.
|
Restart the app. The first SSO sign-in links an existing account with the same email if Authentik marks the email verified. Otherwise sign in with the password and use **Profile → Link Authentik**.
|
||||||
@@ -77,7 +77,7 @@ For domain-level forward auth, Authentik matches each line as a regular expressi
|
|||||||
^https://aircraft\.example\.com/assets/.+$
|
^https://aircraft\.example\.com/assets/.+$
|
||||||
^https://aircraft\.example\.com/shared/[A-Za-z0-9]{32}(/report)?$
|
^https://aircraft\.example\.com/shared/[A-Za-z0-9]{32}(/report)?$
|
||||||
^https://aircraft\.example\.com/rails/active_storage/(blobs/redirect|disk)/.+$
|
^https://aircraft\.example\.com/rails/active_storage/(blobs/redirect|disk)/.+$
|
||||||
^https://aircraft\.example\.com/sign/[A-Za-z0-9_-]{43}(/account)?$
|
^https://aircraft\.example\.com/sign/[A-Za-z0-9_-]{43}$
|
||||||
^https://aircraft\.example\.com/session(/new|/two_factor)?(\?.*)?$
|
^https://aircraft\.example\.com/session(/new|/two_factor)?(\?.*)?$
|
||||||
^https://aircraft\.example\.com/profile/certificates(\?.*)?$
|
^https://aircraft\.example\.com/profile/certificates(\?.*)?$
|
||||||
^https://aircraft\.example\.com/profile/two_factor(/new|/recovery_codes)?(\?.*)?$
|
^https://aircraft\.example\.com/profile/two_factor(/new|/recovery_codes)?(\?.*)?$
|
||||||
@@ -93,13 +93,15 @@ What each group is for:
|
|||||||
| `/assets/…` | Styles and scripts for share pages and the signing pages | Static files with no data |
|
| `/assets/…` | Styles and scripts for share pages and the signing pages | Static files with no data |
|
||||||
| `/shared/<token>`, `/shared/<token>/report` | Read-only share links (Access & Sharing) | Only with a valid, unexpired, unrevoked 32-character token, and only what that link's level shows |
|
| `/shared/<token>`, `/shared/<token>/report` | Read-only share links (Access & Sharing) | Only with a valid, unexpired, unrevoked 32-character token, and only what that link's level shows |
|
||||||
| `/rails/active_storage/blobs/redirect/…`, `/rails/active_storage/disk/…` | The aircraft picture and shared documents on share pages | A file only to someone holding its signed link (from a page they could see). Disk links expire after a few minutes; redirect links don't, so a forwarded link keeps working |
|
| `/rails/active_storage/blobs/redirect/…`, `/rails/active_storage/disk/…` | The aircraft picture and shared documents on share pages | A file only to someone holding its signed link (from a page they could see). Disk links expire after a few minutes; redirect links don't, so a forwarded link keeps working |
|
||||||
| `/sign/<token>`, `/sign/<token>/account` | Outside mechanics signing an entry from an emailed invitation | Only with a valid, unused invitation token (43 characters, 14-day expiry, stored as a fingerprint) |
|
| `/sign/<token>` | Outside mechanics signing an entry from an emailed invitation (with an account they already have) | Only with a valid, unused invitation token (43 characters, 14-day expiry, stored as a fingerprint) |
|
||||||
| `/session`, `/session/new`, `/session/two_factor` | The app's own sign-in, for invited mechanics | The sign-in page. Protected by rate limits, the account lockout (10 failures lock an account for 15 minutes) and optional authenticator codes. A signed-in app account still can't reach any other page through the proxy |
|
| `/session`, `/session/new`, `/session/two_factor` | The app's own sign-in, for invited mechanics | The sign-in page. Protected by rate limits, the account lockout (10 failures lock an account for 15 minutes) and optional authenticator codes. A signed-in app account still can't reach any other page through the proxy |
|
||||||
| `/profile/certificates` | Invited mechanics adding their certificate before signing | Adding a certificate to their own account; it only returns to a `/sign/…` page |
|
| `/profile/certificates` | Invited mechanics adding their certificate before signing | Adding a certificate to their own account; it only returns to a `/sign/…` page |
|
||||||
| `/profile/two_factor…` | Invited mechanics setting up an authenticator app | Their own two-factor setup |
|
| `/profile/two_factor…` | Invited mechanics setting up an authenticator app | Their own two-factor setup |
|
||||||
| `/help/records` | The "How signing works" link on the signing form | The signing instructions, for signed-in accounts |
|
| `/help/records` | The "How signing works" link on the signing form | The signing instructions, for signed-in accounts |
|
||||||
| `/calendar/<token>.ics` | Calendar apps fetching the due-items feed (Profile → Calendar feed) | The due list of that user's aircraft, only with their secret 32-character token; making a new link retires the old one |
|
| `/calendar/<token>.ics` | Calendar apps fetching the due-items feed (Profile → Calendar feed) | The due list of that user's aircraft, only with their secret 32-character token; making a new link retires the old one |
|
||||||
|
|
||||||
|
New accounts come only from an administrator or an administrator's invitation: opening the invitation link, then **Continue with Authentik**, makes the account and accepts it. With `OIDC_AUTO_CREATE_USERS=true` instead, anyone Authentik lets in gets an account (with no aircraft) without an invitation.
|
||||||
|
|
||||||
Invitation links (`/join/…`) are deliberately not on the list: behind forward auth, someone with only an app account still couldn't get past the proxy to use the app, so invited people need an Authentik account anyway. They sign in to Authentik, then open the link and accept it.
|
Invitation links (`/join/…`) are deliberately not on the list: behind forward auth, someone with only an app account still couldn't get past the proxy to use the app, so invited people need an Authentik account anyway. They sign in to Authentik, then open the link and accept it.
|
||||||
|
|
||||||
Leave out lines for features you don't use: without share links drop `/shared` and Active Storage; without calendar feeds drop `/calendar`; if mechanics never sign through invitations drop `/sign`, `/session`, `/profile/…` and `/help/records`.
|
Leave out lines for features you don't use: without share links drop `/shared` and Active Storage; without calendar feeds drop `/calendar`; if mechanics never sign through invitations drop `/sign`, `/session`, `/profile/…` and `/help/records`.
|
||||||
@@ -112,7 +114,7 @@ In a private window:
|
|||||||
|
|
||||||
1. `https://aircraft.example.com/` should go to Authentik.
|
1. `https://aircraft.example.com/` should go to Authentik.
|
||||||
2. A share link should open without signing in, styled, with the aircraft picture.
|
2. A share link should open without signing in, styled, with the aircraft picture.
|
||||||
3. A signing invitation should let you create an account (or sign in), add a certificate and sign.
|
3. A signing invitation should let you sign in (with an existing account), add a certificate and sign.
|
||||||
4. After that, `https://aircraft.example.com/aircraft` in the same window should still go to Authentik.
|
4. After that, `https://aircraft.example.com/aircraft` in the same window should still go to Authentik.
|
||||||
|
|
||||||
### Client addresses
|
### Client addresses
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ To give someone a role on any aircraft, open them in **Admin → Users**: **Airc
|
|||||||
|
|
||||||
## Invitations
|
## Invitations
|
||||||
|
|
||||||
**Admin → Invitations → New invitation** makes a link someone opens to create their own account (or accept with the one they have) and get roles on aircraft: a label for you, optionally an email address (then only that address can use it, and the link is emailed to it when email is set up) and a name, how many times it works (empty for unlimited, e.g. for a flying club), when it expires (empty for never), and a role on any of the aircraft (none at all gives just an account). The link is shown once, when it's made; copy it then.
|
**Admin → Invitations → New invitation** makes a link someone opens to create their own account (or accept with the one they have) and get roles on aircraft. New accounts are only ever made by an administrator: here, from **Users**, or by an administrator's invitation (invitations from an aircraft's Access page are for people who already have an account, and so are signing invitations). An invitation has a label for you, optionally an email address (then only that address can use it, and the link is emailed to it when email is set up) and a name, how many times it works (empty for unlimited, e.g. for a flying club), when it expires (empty for never), and a role on any of the aircraft (none at all gives just an account). The link is shown once, when it's made; copy it then.
|
||||||
|
|
||||||
Where someone already has a role on an aircraft, an invitation leaves it as it is. An invitation never gives more than whoever made it can give when it's used. **Revoke** stops a link working; people who already used it keep their access. With sign-in by single sign-on only, people accept invitations after signing in with it.
|
Where someone already has a role on an aircraft, an invitation leaves it as it is. An invitation never gives more than whoever made it can give when it's used. **Revoke** stops a link working; people who already used it keep their access. With single sign-on, **Continue with** on the invitation page signs them in and makes their account. `OIDC_AUTO_CREATE_USERS=true` in the server's settings instead gives an account to anyone the provider lets in, without an invitation; leave it off to keep accounts to administrators and their invitations.
|
||||||
|
|
||||||
## Account recovery from the command line
|
## Account recovery from the command line
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -123,7 +123,7 @@ POST /api/v1/aircraft/12/draft_batches
|
|||||||
- **One entry per logbook.** Items are grouped by `log` (`AC`, `ENG`, `PROP` or `OTHER`) into one unsigned entry each, their texts in order, so a visit that touched the engine and the airframe makes two entries, signed one after the other.
|
- **One entry per logbook.** Items are grouped by `log` (`AC`, `ENG`, `PROP` or `OTHER`) into one unsigned entry each, their texts in order, so a visit that touched the engine and the airframe makes two entries, signed one after the other.
|
||||||
- **Inspections** (`completes_inspections`): each needs its `result`, `approved` (airworthy) or `discrepancies` (a list was given to the owner), and the draft needs `aircraft_hours`. The entry recording it is an inspection entry, in the logbook named by `log`, else the airframe log if an item is for it.
|
- **Inspections** (`completes_inspections`): each needs its `result`, `approved` (airworthy) or `discrepancies` (a list was given to the owner), and the draft needs `aircraft_hours`. The entry recording it is an inspection entry, in the logbook named by `log`, else the airframe log if an item is for it.
|
||||||
- **Nothing is resolved until it's signed.** The squawks the items resolve and the inspections they complete are held until **every** entry of the draft is signed; then they're resolved and recorded, attributed to the person who signed last, and linked to the entry that described the work. A draft never clears a squawk on its own. The signer sees what signing will do before they sign.
|
- **Nothing is resolved until it's signed.** The squawks the items resolve and the inspections they complete are held until **every** entry of the draft is signed; then they're resolved and recorded, attributed to the person who signed last, and linked to the entry that described the work. A draft never clears a squawk on its own. The signer sees what signing will do before they sign.
|
||||||
- **The signer.** Anyone with access to the aircraft and a certificate in their profile can sign, from each entry's `sign_url`. Give `signer.email` for someone else (a mechanic without an account): each entry then gets an `invitation_url`, a link that lets that person create an account for that address and sign that entry, for 14 days. Pass the link on yourself (for example inside Redmine), or set `send_email: true` to have SAM email it.
|
- **The signer.** Anyone with access to the aircraft and a certificate in their profile can sign, from each entry's `sign_url`. Give `signer.email` for someone else (a mechanic who isn't on the aircraft): each entry then gets an `invitation_url`, a link that lets that person sign that entry with their account for that address, for 14 days. They need an account first (the administrator adds it, or invites them). Pass the link on yourself (for example inside Redmine), or set `send_email: true` to have SAM email it.
|
||||||
|
|
||||||
The answer (`201`):
|
The answer (`201`):
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ A signed entry can't be edited or deleted. Open it and choose **More → Correct
|
|||||||
|
|
||||||
## Someone else did the work
|
## Someone else did the work
|
||||||
|
|
||||||
The owner can choose **More → Ask someone to sign** on the entry. The mechanic gets a one-time email link (valid for 14 days), signs in or creates their own account, adds their certificate and signs.
|
The owner can choose **More → Ask someone to sign** on the entry. The mechanic gets a one-time email link (valid for 14 days), signs in with their own account (the administrator adds it first, or invites them), adds their certificate and signs.
|
||||||
|
|
||||||
If they prefer paper, print the entry (**Print for logbook**), have it signed in ink, and keep the paper with the logbooks (scan it into Documents).
|
If they prefer paper, print the entry (**Print for logbook**), have it signed in ink, and keep the paper with the logbooks (scan it into Documents).
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ Only an Owner can give or take away the Owner role, nobody can change their own,
|
|||||||
|
|
||||||
## Invitations
|
## Invitations
|
||||||
|
|
||||||
To add someone who has no account yet, or without knowing their email, use **Invitations** on the same page: choose the role, optionally their email (then only they can use it, and it's emailed to them when email is set up), how many times it works and when it expires, then **Create invitation**. Copy the link shown and send it; it isn't shown again. Whoever opens it creates an account, or signs in, and gets the role on this aircraft. **Revoke** stops a link that hasn't been used. Administrators can also make invitations for several aircraft at once (Admin → Invitations).
|
To bring in someone who has an account, without knowing their email, use **Invitations** on the same page (new accounts are made only by the administrator or an administrator's invitation, so ask the administrator for someone who has no account yet): choose the role, optionally their email (then only they can use it, and it's emailed to them when email is set up), how many times it works and when it expires, then **Create invitation**. Copy the link shown and send it; it isn't shown again. Whoever opens it creates an account, or signs in, and gets the role on this aircraft. **Revoke** stops a link that hasn't been used. Administrators can also make invitations for several aircraft at once (Admin → Invitations).
|
||||||
|
|
||||||
## Share links
|
## Share links
|
||||||
|
|
||||||
|
|||||||
@@ -159,6 +159,7 @@ class ElectronicSignaturesTest < ActionDispatch::IntegrationTest
|
|||||||
post aircraft_logbook_entry_signing_invitations_path(@a, @entry), params: { signing_invitation: { email: "Outside@Example.com", message: "Thanks!" } }
|
post aircraft_logbook_entry_signing_invitations_path(@a, @entry), params: { signing_invitation: { email: "Outside@Example.com", message: "Thanks!" } }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
assert_match "They don't have an account here yet", flash[:notice]
|
||||||
mail = ActionMailer::Base.deliveries.last
|
mail = ActionMailer::Base.deliveries.last
|
||||||
assert_equal [ "outside@example.com" ], mail.to
|
assert_equal [ "outside@example.com" ], mail.to
|
||||||
path = mail.text_part.body.to_s[%r{http://example\.com(/sign/[\w-]+)}, 1]
|
path = mail.text_part.body.to_s[%r{http://example\.com(/sign/[\w-]+)}, 1]
|
||||||
@@ -166,8 +167,16 @@ class ElectronicSignaturesTest < ActionDispatch::IntegrationTest
|
|||||||
|
|
||||||
get path
|
get path
|
||||||
assert_includes response.body, "sign in as <strong>outside@example.com</strong>"
|
assert_includes response.body, "sign in as <strong>outside@example.com</strong>"
|
||||||
|
assert_includes response.body, "no account for outside@example.com yet" # a signing link doesn't make accounts
|
||||||
post "#{path}/account", params: { name: "Olive Outside", password: "longpassword1", password_confirmation: "longpassword1" }
|
post "#{path}/account", params: { name: "Olive Outside", password: "longpassword1", password_confirmation: "longpassword1" }
|
||||||
assert_redirected_to path
|
assert_response :not_found
|
||||||
|
assert_not User.exists?(email_address: "outside@example.com")
|
||||||
|
|
||||||
|
# The administrator adds their account; they sign in and come back to the link.
|
||||||
|
User.create!(email_address: "outside@example.com", name: "Olive Outside", password: "longpassword1")
|
||||||
|
get path
|
||||||
|
post session_path, params: { email_address: "outside@example.com", password: "longpassword1" }
|
||||||
|
assert_redirected_to "http://www.example.com#{path}"
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert_select "form[action='#{certificates_path(return_to: path)}']" # add a certificate first
|
assert_select "form[action='#{certificates_path(return_to: path)}']" # add a certificate first
|
||||||
post certificates_path(return_to: path), params: { user_certificate: { kind: "IA", number: "2222222" } }
|
post certificates_path(return_to: path), params: { user_certificate: { kind: "IA", number: "2222222" } }
|
||||||
|
|||||||
@@ -166,4 +166,26 @@ class InvitationsTest < ActionDispatch::IntegrationTest
|
|||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
assert_not inv.reload.revoked?
|
assert_not inv.reload.revoked?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "only an administrator's invitation makes new accounts; an owner's is for existing accounts" do
|
||||||
|
owners = invitation(creator: @owner, grants: [ [ @a, "pilot" ] ])
|
||||||
|
get join_path(owners.token)
|
||||||
|
assert_select "form[action=?]", account_join_path(owners.token), 0
|
||||||
|
assert_includes response.body, "This invitation is for an existing account"
|
||||||
|
post account_join_path(owners.token), params: { email_address: "new@example.com", name: "X", password: PASSWORD, password_confirmation: PASSWORD }
|
||||||
|
assert_not User.exists?(email_address: "new@example.com")
|
||||||
|
assert_equal 0, owners.reload.uses_count
|
||||||
|
|
||||||
|
existing = create_user("existing@example.com")
|
||||||
|
sign_in existing
|
||||||
|
post accept_join_path(owners.token)
|
||||||
|
assert_equal "pilot", existing.role_for(@a).key
|
||||||
|
end
|
||||||
|
|
||||||
|
test "an administrator's invitation stops making accounts once its creator isn't an administrator" do
|
||||||
|
inv = invitation
|
||||||
|
@admin.update!(admin: false)
|
||||||
|
post account_join_path(inv.token), params: { email_address: "new@example.com", name: "X", password: PASSWORD, password_confirmation: PASSWORD }
|
||||||
|
assert_not User.exists?(email_address: "new@example.com")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@@ -130,4 +130,43 @@ class SsoTest < ActionDispatch::IntegrationTest
|
|||||||
get "/auth/oidc/callback"
|
get "/auth/oidc/callback"
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "signing in with SSO makes an account only from an administrator's invitation" do
|
||||||
|
ENV.delete("OIDC_AUTO_CREATE_USERS")
|
||||||
|
mock(uid: "sub-new", email: "newbie@example.com", name: "New Bie")
|
||||||
|
sso_sign_in
|
||||||
|
assert_redirected_to new_session_path
|
||||||
|
assert_not User.exists?(email_address: "newbie@example.com")
|
||||||
|
|
||||||
|
owner = create_user("owner2@example.com")
|
||||||
|
aircraft = create_aircraft(owner: owner, tail_number: "N777AB")
|
||||||
|
owners = AccessInvitation.create_for(owner, { label: "From the owner", max_uses: 1 }, [ [ aircraft, Role.for_key("pilot") ] ])
|
||||||
|
get join_path(owners.token)
|
||||||
|
assert_select "form[action='/auth/oidc']", 0
|
||||||
|
sso_sign_in
|
||||||
|
assert_not User.exists?(email_address: "newbie@example.com")
|
||||||
|
|
||||||
|
admin = create_user("boss@example.com", admin: true)
|
||||||
|
invitation = AccessInvitation.create_for(admin, { label: "Club", max_uses: 1 }, [ [ aircraft, Role.for_key("pilot") ] ])
|
||||||
|
get join_path(invitation.token)
|
||||||
|
assert_select "form[action='/auth/oidc'] button", text: "Continue with Authentik"
|
||||||
|
sso_sign_in
|
||||||
|
assert_redirected_to root_url
|
||||||
|
assert_match "Welcome! Your account is ready. N777AB: Pilot", flash[:notice]
|
||||||
|
newbie = User.find_by!(email_address: "newbie@example.com")
|
||||||
|
assert_equal "sub-new", newbie.sso_uid
|
||||||
|
assert_equal "pilot", newbie.role_for(aircraft).key
|
||||||
|
assert_equal 1, invitation.reload.uses_count
|
||||||
|
end
|
||||||
|
|
||||||
|
test "an administrator's invitation for one address makes an account only for that address" do
|
||||||
|
ENV.delete("OIDC_AUTO_CREATE_USERS")
|
||||||
|
admin = create_user("boss@example.com", admin: true)
|
||||||
|
invitation = AccessInvitation.create_for(admin, { label: "For Kim", email: "kim@example.com", max_uses: 1 }, [])
|
||||||
|
get join_path(invitation.token)
|
||||||
|
mock(uid: "sub-x", email: "someone.else@example.com")
|
||||||
|
sso_sign_in
|
||||||
|
assert_not User.exists?(email_address: "someone.else@example.com")
|
||||||
|
assert_equal 0, invitation.reload.uses_count
|
||||||
|
end
|
||||||
end
|
end
|
||||||
Reference in new issue
Block a user