mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
Records package viewer: read-only, no account needed
SAM_VIEWER=true (set only by the records package's viewer/docker-compose.yml) makes the app a read-only copy of an archive, for whoever receives the records: `docker compose up`, then open http://localhost:3000. - At start (bin/docker-entrypoint → sam:viewer:prepare) the package's .sam.zip, mounted read-only, is imported once. - No sign-in: everyone browses as a built-in account. Nothing can be changed: any request but GET/HEAD is refused, no role permission applies (so no edit buttons), and there's no sign-out or profile. A banner names the archive and when it was exported. - It refuses to start, and every page answers 503, when the database has any other account, so turning it on for a real installation stops the app instead of exposing its records. - The viewer listens on 127.0.0.1 only, and skips scheduled jobs (reminders, backups, AD searches). - Docs: the package README (three steps now), Access & sharing, README settings and features, the suggested recordkeeping procedures. Checked end to end with a built image and a real records package: the archive imported at start, pages browsed without an account, a change refused, and the container refusing to start once an account existed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
34e3232350
commit
d956cfbe83
14 files changed
+229
-33
No files matched your search
@@ -49,10 +49,11 @@ module AircraftScoped
|
||||
@current_role = current_user.role_for(@aircraft)
|
||||
end
|
||||
|
||||
def can?(permission) = current_user.admin? || current_role&.can?(permission) || false
|
||||
# Nothing in viewer mode (a read-only copy, see Viewer).
|
||||
def can?(permission) = !Viewer.enabled? && (current_user.admin? || current_role&.can?(permission) || false)
|
||||
|
||||
# The Owner role (or an administrator): everything.
|
||||
def owner? = current_user.admin? || current_role&.owner? || false
|
||||
def owner? = !Viewer.enabled? && (current_user.admin? || current_role&.owner? || false)
|
||||
|
||||
def authorize_permission!
|
||||
rules = self.class.permission_rules.select do |_, only, except|
|
||||
|
||||
@@ -21,7 +21,12 @@ module Authentication
|
||||
end
|
||||
|
||||
def require_authentication
|
||||
resume_session || request_authentication
|
||||
resume_session || start_viewer_session || request_authentication
|
||||
end
|
||||
|
||||
# Viewer mode: everyone is its built-in account, without signing in.
|
||||
def start_viewer_session
|
||||
start_new_session_for(Viewer.user) if Viewer.enabled? && !Viewer.real_accounts?
|
||||
end
|
||||
|
||||
def resume_session
|
||||
|
||||
Reference in new issue
Block a user