Electronic signatures on logbook entries (AC 120-78B chapter 2)

- Sign an entry: review exactly what's certified, choose a current
  certificate (eligibility checked: pilot only for preventive maintenance,
  inspections need their result and time), re-enter the password or sign
  in again with SSO (prompt=login, within 5 minutes), and confirm the
  "Certified by" statement (43.9 return to service, 43.11(a)(5) for
  inspections, preventive maintenance for pilots)
- The signature stores signer, certificate, statement, UTC time, how they
  authenticated, IP/browser, a SHA-256 fingerprint of the entry's content
  and a readable snapshot; an HMAC seal covers the signature record. Status
  shows Valid / Superseded / Altered since signing. The signer is emailed
- Signed entries (and their sub-components) can't be edited or deleted;
  a correction entry, once signed, supersedes the original (kept)
- Owners invite an outside mechanic by email to sign one entry: one-time,
  14-day link; they create or use their own account and certificate and
  see only that entry
- Admins can disable accounts (signed out, can't sign in or sign; past
  signatures kept); users with signatures can't be deleted
- Printouts show the electronic signature and fingerprint; archives carry
  signatures (marked imported, with their origin) and corrections

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-07 13:12:04 -05:00
1 parent 7caa213e7a
commit d719f663bc
47 files changed
+1059 -17

No files matched your search

+4 -1
View File
@@ -7,7 +7,10 @@
<td><%= u.email_address %><% if u.certificates.any? %><div class="text-xs text-slate-500"><%= u.certificates.map { "#{_1.short_label} #{_1.number}" }.join(", ") %></div><% end %></td>
<td class="text-xs"><%= u.aircraft_roles.map { "#{_1.aircraft.tail_number} (#{_1.role})" }.join(", ").presence || "—" %></td>
<td class="text-xs text-slate-500"><%= u.last_signed_in_at ? "#{time_ago_in_words(u.last_signed_in_at)} ago" : "never" %></td>
<td class="text-right"><%= link_to "Edit", edit_admin_user_path(u), class: "btn-secondary btn-sm" %></td>
<td class="whitespace-nowrap text-right">
<% if u.disabled? %><span class="badge-red mr-1">Disabled</span><%= button_to "Enable", enable_admin_user_path(u), method: :patch, class: "btn-secondary btn-sm", form: { class: "inline" } %>
<% elsif u != current_user %><%= button_to "Disable", disable_admin_user_path(u), method: :patch, class: "btn-secondary btn-sm", form: { class: "inline", data: { turbo_confirm: "Disable #{u.email_address}? They'll be signed out and can't sign in or sign entries. Their past signatures are kept." } } %><% end %>
<%= link_to "Edit", edit_admin_user_path(u), class: "btn-secondary btn-sm" %></td>
</tr><% end %></tbody>
</table></section>
<p class="hint mt-3">After creating an account, an aircraft owner can grant access from the aircraft's “Access & Sharing” tab.</p>
+51
View File
@@ -0,0 +1,51 @@
<%# Signing form: review, certificate, re-authentication, confirm. Locals: entry, url, cancel_path. %>
<section class="card max-w-3xl">
<div class="card-header"><h2 class="card-title">Sign this entry</h2></div>
<div class="card-body space-y-4">
<p class="text-sm text-slate-600">Review the entry: your signature will cover exactly what's shown here, and it can't be changed afterwards. A mistake is fixed with a correction entry.</p>
<%= render "logbook_entries/content", entry: entry %>
<% if @signing_error %>
<div class="rounded-md bg-red-50 p-3 text-sm text-red-700 ring-1 ring-red-200" role="alert"><%= @signing_error %></div>
<% end %>
<% if @certificates.empty? %>
<p class="rounded-md bg-amber-50 p-3 text-sm text-amber-900 ring-1 ring-amber-200">
To sign, add your certificate on <%= link_to "your profile", edit_profile_path(anchor: "certificates"), class: "link" %>.
</p>
<% else %>
<%= form_with url: url, method: :post, class: "space-y-4" do %>
<fieldset class="space-y-2">
<legend class="label">Sign with</legend>
<% @certificates.each_with_index do |c, i| %>
<% problems = entry.signing_problems(c) %>
<label class="flex items-start gap-2 rounded-md p-2 text-sm ring-1 ring-slate-200 <%= 'opacity-60' if problems.any? %>">
<%= radio_button_tag :certificate_id, c.id, params[:certificate_id].to_s == c.id.to_s || (params[:certificate_id].blank? && i.zero? && problems.empty?),
disabled: problems.any?, class: "mt-1" %>
<span><strong><%= current_user.display_name %>, <%= c.kind_label %> <%= c.number %></strong>
<% if problems.any? %><span class="block text-xs text-red-700">Can't sign: <%= problems.to_sentence %>.</span>
<% else %><span class="block text-slate-600"><%= EntrySignature::LABEL %>: “<%= entry.certification_statement(c.kind) %>”</span><% end %></span>
</label>
<% end %>
</fieldset>
<% if Sso.password_login? || !current_user.sso_uid? %>
<div class="max-w-xs">
<%= label_tag :password, "Your password", class: "label" %>
<%= password_field_tag :password, nil, class: "input", autocomplete: "current-password" %>
<p class="hint">Proves it's you signing, not someone at your keyboard.<%= " Or sign in again with #{Sso.label} below." if Sso.enabled? && current_user.sso_uid? %></p>
</div>
<% end %>
<% if Sso.enabled? && current_user.sso_uid? %>
<% fresh = session[:reauthenticated_at] && Time.zone.at(session[:reauthenticated_at]) > EntrySigner::REAUTH_WINDOW.ago %>
<p class="text-sm <%= fresh ? 'text-emerald-700' : 'text-slate-600' %>"><%= fresh ? "Signed in again with #{Sso.label}: you can sign now." : "Or sign in again with #{Sso.label} first (button below the form)." %></p>
<% end %>
<label class="flex items-start gap-2 text-sm">
<%= check_box_tag :confirm, "1", false, class: "mt-0.5 h-4 w-4 shrink-0 rounded border-slate-300" %>
<span>I am signing this entry myself, with the intent to sign it, and certify the statement above.</span>
</label>
<div class="flex gap-2"><%= submit_tag "Sign entry", class: "btn-primary" %><%= link_to "Cancel", cancel_path, class: "btn-secondary" %></div>
<% end %>
<% if Sso.enabled? && current_user.sso_uid? %>
<%= button_to "Sign in again with #{Sso.label}", "/auth/#{Sso::PROVIDER}", params: { prompt: "login" }, class: "btn-secondary btn-sm", data: { turbo: false } %>
<% end %>
<% end %>
</div>
</section>
+4
View File
@@ -0,0 +1,4 @@
<% content_for :title, "Sign logbook entry" %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "entry_signatures/form", entry: @entry, url: aircraft_logbook_entry_signature_path(@aircraft, @entry),
cancel_path: aircraft_logbook_entry_path(@aircraft, @entry) %>
@@ -0,0 +1,5 @@
<% content_for :title, "Invitation not found" %>
<div class="mx-auto max-w-md card card-body">
<h1 class="card-title">This signing link has expired or was already used</h1>
<p class="mt-1 text-sm text-slate-600">Ask the aircraft's owner to send a new one.</p>
</div>
+12
View File
@@ -0,0 +1,12 @@
<% content_for :title, "Sign logbook entry" %>
<% if @certificates.empty? %>
<section class="card card-body mb-5 max-w-3xl space-y-3">
<h2 class="card-title">Add your certificate</h2>
<%= form_with model: UserCertificate.new, url: certificates_path(return_to: request.path), class: "grid gap-2 sm:grid-cols-[1fr_10rem_auto]" do |f| %>
<%= f.select :kind, UserCertificate::KINDS.invert, {}, class: "input", "aria-label": "Kind of certificate" %>
<%= f.text_field :number, class: "input", placeholder: "Number", required: true, "aria-label": "Certificate number" %>
<%= f.submit "Add", class: "btn-secondary" %>
<% end %>
</section>
<% end %>
<%= render "entry_signatures/form", entry: @entry, url: invited_signing_path(params[:token]), cancel_path: root_path %>
@@ -0,0 +1,6 @@
<% content_for :title, "Logbook entry signed" %>
<div class="mx-auto max-w-3xl space-y-4">
<h1 class="text-2xl font-bold">Entry signed</h1>
<%= render "logbook_entries/signature", entry: @entry %>
<%= render "logbook_entries/content", entry: @entry %>
</div>
@@ -0,0 +1,19 @@
<% content_for :title, "Sign a logbook entry" %>
<div class="mx-auto max-w-md space-y-4">
<h1 class="text-2xl font-bold">Sign a logbook entry</h1>
<p class="text-sm text-slate-600">You've been asked to sign the <%= @entry.date %> <%= LogbookEntry::LOG_TYPES[@entry.log_type].downcase %> log entry for <%= @entry.aircraft.tail_number %>. First, sign in as <strong><%= @invitation.email %></strong>.</p>
<div class="card card-body space-y-3">
<%= link_to "I have an account: sign in", new_session_path, class: "btn-primary w-full justify-center" %>
</div>
<% if Sso.password_login? && !User.exists?(email_address: @invitation.email) %>
<%= form_with url: account_invited_signing_path(params[:token]), class: "card card-body space-y-3" do %>
<h2 class="card-title">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">Email</label><input class="input" value="<%= @invitation.email %>" disabled></div>
<div><%= label_tag :name, "Your name", class: "label" %><%= text_field_tag :name, params[:name], class: "input", required: true %></div>
<div><%= label_tag :password, "Password", class: "label" %><%= password_field_tag :password, nil, class: "input", required: true, autocomplete: "new-password" %></div>
<div><%= label_tag :password_confirmation, "Confirm password", class: "label" %><%= password_field_tag :password_confirmation, nil, class: "input", required: true, autocomplete: "new-password" %></div>
<%= submit_tag "Create account", class: "btn-secondary" %>
<% end %>
<% end %>
</div>
@@ -0,0 +1,6 @@
<% content_for :title, "Sign a logbook entry" %>
<div class="mx-auto max-w-md card card-body space-y-3">
<h1 class="card-title">Wrong account</h1>
<p class="text-sm text-slate-600">This invitation is for <strong><%= @invitation.email %></strong>, but you're signed in as <%= current_user.email_address %>. Sign out and sign in with the invited address.</p>
<%= button_to "Sign out", session_path, method: :delete, class: "btn-secondary" %>
</div>
@@ -0,0 +1,19 @@
<%# Everything a signature covers, as the signer reviews it (AC 120-78B 2.2.4). %>
<dl class="grid gap-x-4 gap-y-1 text-sm sm:grid-cols-[10rem_1fr]">
<dt class="text-slate-500">Aircraft</dt><dd><%= entry.aircraft.tail_number %> <%= [ entry.aircraft.make, entry.aircraft.model ].compact_blank.join(" ") %><%= " · S/N #{entry.aircraft.serial_number}" if entry.aircraft.serial_number.present? %></dd>
<dt class="text-slate-500">Date</dt><dd><%= fmt_date(entry.date) %></dd>
<dt class="text-slate-500">Logbook</dt><dd><%= LogbookEntry::LOG_TYPES[entry.log_type] %> · <%= LogbookEntry::ENTRY_TYPES[entry.entry_type] %></dd>
<dt class="text-slate-500">Airframe total time</dt><dd><%= hours(entry.aircraft_hours_at_entry) %> (<%= entry.aircraft.time_basis %>)</dd>
<% if (c = entry.component) %>
<dt class="text-slate-500"><%= c.component_type&.name %></dt>
<dd><%= c.manufacturer %> <%= c.model %><%= " · S/N #{c.serial_number}" if c.serial_number.present? %> · <%= hours(entry.component_hours_at_entry) %> total, <%= hours(entry.component_since_overhaul_at_entry) %> <%= c.since_overhaul_abbreviation %></dd>
<% end %>
<% entry.parts.each do |part| %>
<dt class="text-slate-500"><%= part.component.component_type&.name %></dt>
<dd><%= part.component.manufacturer %> <%= part.component.model %><%= " · S/N #{part.component.serial_number}" if part.component.serial_number.present? %> · <%= hours(part.hours_at_entry) %> total, <%= hours(part.since_overhaul_at_entry) %> <%= part.component.since_overhaul_abbreviation.downcase %></dd>
<% end %>
<% if entry.inspection_result %><dt class="text-slate-500">Result</dt><dd><%= entry.inspection_result_label %></dd><% end %>
<% if entry.signoff_location.present? %><dt class="text-slate-500">Location</dt><dd><%= entry.signoff_location %></dd><% end %>
<% if entry.supersedes %><dt class="text-slate-500">Corrects</dt><dd>The <%= entry.supersedes.date %> entry</dd><% end %>
</dl>
<div class="mt-3 whitespace-pre-wrap rounded bg-slate-50 p-3 font-mono text-sm"><%= entry.text %></div>
+7
View File
@@ -1,5 +1,12 @@
<%= form_with model: [aircraft, entry], class: "card card-body space-y-4 max-w-3xl", data: { controller: "entry-template signer component-times", component_times_aircraft_hours_value: aircraft.current_hours.to_f } do |f| %>
<%= f.errors_summary %>
<% if entry.supersedes %>
<%= f.hidden_field :supersedes_id %>
<p class="rounded-md bg-amber-50 px-3 py-2 text-sm text-amber-900 ring-1 ring-amber-200">
Correcting the signed <%= link_to "#{entry.supersedes.date} entry", aircraft_logbook_entry_path(aircraft, entry.supersedes), class: "link" %>.
Change what's wrong, save, then sign it: the original's signature is then marked superseded (it's kept, not deleted).
</p>
<% end %>
<% templates = entry.new_record? ? LogbookTemplate.ordered.to_a : [] %>
<% if templates.any? %>
<div>
@@ -0,0 +1,14 @@
<%# The signature block on an entry's page. %>
<% sig = entry.signature %>
<% box, title = { valid: [ "bg-emerald-50 ring-emerald-200", "text-emerald-900" ], superseded: [ "bg-amber-50 ring-amber-200", "text-amber-900" ],
altered: [ "bg-red-50 ring-red-200", "text-red-900" ] }.fetch(sig.imported? ? :valid : sig.status) %>
<div class="rounded-md p-3 text-sm ring-1 <%= box %>">
<div class="font-medium <%= title %>"><%= EntrySignature::LABEL %> <%= sig.signer_name %>, <%= sig.certificate_label %> <%= sig.certificate_number %></div>
<div class="text-slate-700">Signed electronically <%= sig.signed_at.utc.strftime("%Y-%m-%d %H:%M UTC") %><%= " (#{EntrySignature::AUTH_METHODS[sig.auth_method]})" if EntrySignature::AUTH_METHODS[sig.auth_method] %></div>
<div class="mt-1 italic text-slate-700">“<%= sig.statement %>”</div>
<div class="mt-1 text-xs text-slate-500">
Status: <strong><%= sig.imported? ? "Signed on #{sig.origin} (imported)" : sig.status_label %></strong>
· Fingerprint <span class="font-mono"><%= sig.content_digest.first(16) %>…</span>
<% if entry.superseded_by %> · Corrected by <%= link_to "the #{entry.superseded_by.date} entry", aircraft_logbook_entry_path(entry.aircraft, entry.superseded_by), class: "link" %><% end %>
</div>
</div>
+2 -1
View File
@@ -31,7 +31,8 @@
<td class="max-w-xl"><%= e.text.truncate(220) %> <%= "📄" if e.document %>
<% unless e.verified? %><span class="badge-orange" title="Transcribed by Claude<%= " (#{e.transcription_confidence} confidence)" if e.transcription_confidence %>; check it against the scan">Unverified</span><% end %></td>
<td class="text-xs text-slate-500"><%= e.signoff_person %><%= " ##{e.signoff_certificate_number}" if e.signoff_certificate_number %><% if e.signoff_location.present? %><br><%= e.signoff_location %><% end %>
<% if (missing = e.missing_record_items).any? %><br><span class="badge-orange" title="Missing: <%= missing.to_sentence %>">Incomplete</span><% end %></td>
<% if e.signature %><br><span class="<%= e.superseded? ? 'badge-orange' : 'badge-green' %>" title="Signed electronically by <%= e.signature.signer_name %>"><%= e.superseded? ? "Superseded" : "Signed" %></span>
<% elsif (missing = e.missing_record_items).any? %><br><span class="badge-orange" title="Missing: <%= missing.to_sentence %>">Incomplete</span><% end %></td>
</tr>
<% end %>
</tbody>
+13 -1
View File
@@ -4,10 +4,22 @@
<h2 class="card-title"><%= LogbookEntry::LOG_TYPES[@entry.log_type] %> log — <%= fmt_date(@entry.date) %></h2>
<div class="flex gap-2">
<%= link_to "Print for logbook", new_aircraft_logbook_print_path(@aircraft, ids: [ @entry.id ]), class: "btn-secondary btn-sm" %>
<% if owner? %><%= link_to "Edit", edit_aircraft_logbook_entry_path(@aircraft, @entry), class: "btn-secondary btn-sm" %><% end %>
<% if @entry.signed? %>
<% if owner? && !@entry.superseded? && !@entry.superseded_by %><%= link_to "Correct this entry", new_aircraft_logbook_entry_path(@aircraft, supersedes: @entry.id), class: "btn-secondary btn-sm" %><% end %>
<% else %>
<%= link_to "Sign", new_aircraft_logbook_entry_signature_path(@aircraft, @entry), class: "btn-primary btn-sm" %>
<% if owner? %>
<%= link_to "Ask someone to sign", new_aircraft_logbook_entry_signing_invitation_path(@aircraft, @entry), class: "btn-secondary btn-sm" %>
<%= link_to "Edit", edit_aircraft_logbook_entry_path(@aircraft, @entry), class: "btn-secondary btn-sm" %>
<% end %>
<% end %>
</div>
</div>
<div class="card-body space-y-3">
<% if @entry.signed? %><%= render "logbook_entries/signature", entry: @entry %>
<% elsif LogbookEntry::RECORD_TYPES.include?(@entry.entry_type) %>
<p class="rounded-md bg-slate-50 px-3 py-2 text-sm text-slate-600 ring-1 ring-slate-200">Not signed electronically.<%= " Pending correction of the #{@entry.supersedes.date} entry." if @entry.supersedes %> Sign it here, or print it and sign the paper copy.</p>
<% end %>
<% unless @entry.verified? %>
<div class="flex flex-wrap items-center justify-between gap-2 rounded-md bg-amber-50 px-3 py-2 text-sm text-amber-900 ring-1 ring-amber-200">
<span>Transcribed by Claude<%= " (#{@entry.transcription_confidence} confidence)" if @entry.transcription_confidence %> and not yet checked. Compare it with the scan<%= @entry.document ? "" : " or the paper logbook" %> before relying on it.</span>
@@ -0,0 +1,8 @@
<p>You electronically signed a logbook entry.</p>
<p>Aircraft: <strong><%= @entry.aircraft.tail_number %></strong><br>
Entry: <%= @entry.date %>, <%= LogbookEntry::LOG_TYPES[@entry.log_type] %> log<br>
Certified by: <%= @signature.signer_name %>, <%= @signature.certificate_label %> <%= @signature.certificate_number %><br>
Signed: <%= @signature.signed_at.utc.strftime("%Y-%m-%d %H:%M:%S UTC") %></p>
<p>Statement: <em><%= @signature.statement %></em></p>
<p style="color:#64748b;font-size:12px">Fingerprint: <%= @signature.content_digest %></p>
<p>If you didn't sign this, tell the aircraft's owner right away.</p>
@@ -0,0 +1,10 @@
You electronically signed a logbook entry.
Aircraft: <%= @entry.aircraft.tail_number %>
Entry: <%= @entry.date %>, <%= LogbookEntry::LOG_TYPES[@entry.log_type] %> log
Certified by: <%= @signature.signer_name %>, <%= @signature.certificate_label %> <%= @signature.certificate_number %>
Signed: <%= @signature.signed_at.utc.strftime("%Y-%m-%d %H:%M:%S UTC") %>
Statement: <%= @signature.statement %>
Fingerprint: <%= @signature.content_digest %>
If you didn't sign this, tell the aircraft's owner right away.
@@ -0,0 +1,4 @@
<p><%= @invitation.invited_by&.display_name || "The owner" %> asks you to sign a logbook entry for <strong><%= @entry.aircraft.tail_number %></strong> (<%= @entry.date %>, <%= LogbookEntry::LOG_TYPES[@entry.log_type] %> log).</p>
<% if @invitation.message.present? %><p><em>“<%= @invitation.message %>”</em></p><% end %>
<p><%= link_to "Review and sign the entry", @url %> (the link works once, until <%= @invitation.expires_at.to_date %>).</p>
<p style="color:#64748b;font-size:12px">You'll sign in or create an account for <%= @invitation.email %>, add your certificate, and sign with your password.</p>
@@ -0,0 +1,10 @@
<%= @invitation.invited_by&.display_name || "The owner" %> asks you to sign a logbook entry for <%= @entry.aircraft.tail_number %> (<%= @entry.date %>, <%= LogbookEntry::LOG_TYPES[@entry.log_type] %> log).
<% if @invitation.message.present? %>
"<%= @invitation.message %>"
<% end %>
Review and sign it here (the link works once, until <%= @invitation.expires_at.to_date %>):
<%= @url %>
You'll sign in or create an account for <%= @invitation.email %>, add your certificate, and sign with your password.
@@ -0,0 +1,11 @@
<% content_for :title, "Ask someone to sign" %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= form_with model: @invitation, url: aircraft_logbook_entry_signing_invitations_path(@aircraft, @entry), class: "card card-body max-w-2xl space-y-4" do |f| %>
<h2 class="card-title">Ask someone to sign</h2>
<p class="text-sm text-slate-600">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.</p>
<%= f.errors_summary %>
<div class="rounded-md bg-slate-50 p-3 text-sm"><%= @entry.date %> · <%= LogbookEntry::LOG_TYPES[@entry.log_type] %> log · <%= @entry.text.truncate(160) %></div>
<%= f.field :email, as: :email, label: "Their email", required: true %>
<%= f.field :message, as: :textarea, rows: 2, label: "Message (optional)" %>
<div class="flex gap-2"><%= f.submit "Send invitation" %><%= link_to "Cancel", aircraft_logbook_entry_path(@aircraft, @entry), class: "btn-secondary" %></div>
<% end %>