Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ version may change things that need attention when updating, and these notes say

### For people running an archive

- Accounts have a **name** (optional, set by an admin) and show when the person last logged in. Both are visible to admins
only, on the Accounts pages. The activity log still names the account by its email address as it was at the time.
- A new account type, **Helper**, for volunteers: they describe items and add photos, but cannot publish, unpublish, delete,
open contributions that are still to be reviewed, or see who contributed something. Admins choose the type under
Accounts. The handbook has a section on a scanning evening with helpers.
Expand Down
4 changes: 4 additions & 0 deletions docs/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ their own email, a message, or in person), and the person chooses their own pass
and for seven days. If someone forgets their password, an admin creates a new setup link; earlier links stop
working then.

An account can have a display name, and Commonage remembers when it last logged in (table `StaffProfiles`). Both are shown to
admins on the Accounts pages only, and are not part of the export, which holds no accounts. The activity log names the account
by the email address it had when something was done, so it stays true after a rename or a deleted account.

Disabling an account ends its logins within a minute. Admins cannot change, disable or delete their own account, so
there is always at least one admin left. Everyone changes their own password under "Change password".

Expand Down
3 changes: 2 additions & 1 deletion docs/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,8 @@ shows the years of its published items. M19 is complete.

**M24 Helpers and accounts**

- Part 1 is done: the `Helper` role. Display names and a last login are still to do.
- Part 1 is done: the `Helper` role. Part 2: `StaffProfiles` (display name, last login), shown to admins only; the activity log
keeps the email address as at the time, so it stays true after a rename.
- A `Helper` role: describes and uploads. Publishing, the bin, contributors, notes, export and settings stay with curators,
and contributors' names and email addresses are not shown. `EndpointAccessTests` checks every role against every admin
address. Display names and a last login for accounts.
Expand Down
1 change: 1 addition & 0 deletions docs/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ vulnerability, see [SECURITY.md](../SECURITY.md).
| Access | Public pages and public image addresses read only from published items (`PublishedItems`). Admin pages are protected by policy per folder; admin-only pages (accounts, export, activity log) by a second policy. Originals and previews of unpublished items are served only to curators. What a curator chooses ahead of publishing, such as a draft's photo as a collection's cover, is passed over until its item is published. Tested in `PublicationTests`, `MediaTests`, `AccountTests`, `ExportTests`, `CollectionTests`. `EndpointAccessTests` lists every address that is open without a login, so a new one cannot be open by accident. |
| Accounts | Passwords of at least 12 characters (length over forced symbols, NIST SP 800-63B). Five wrong passwords lock an account for five minutes, and one address can try 100 logins an hour. Accounts are created with one-time setup links, valid seven days. Disabling an account, or a password change, ends its logins within a minute. Admins cannot lock themselves out. An authenticator app (TOTP) can be added to each login, and admins can require it of everyone who manages the archive; wrong codes count towards the lockout like wrong passwords. Ten recovery codes, each usable once. Turning the app off or making new codes asks for the password again, and wrong passwords there and on "Change password" count towards the lockout too. Tested in `TwoFactorTests`. |
| Forms | Every form carries an antiforgery token. Redirects after login and language change only go to addresses on this site. |
| Staff names and last login | `StaffProfiles` holds an optional display name and the time of the last login per account, written after a successful login (password, authenticator code or recovery code). Read only on the admin-only Accounts pages, never on a public page, feed or link preview, and not in the export or the activity log (which keeps the email address). Changing a name is logged. The row goes with the account (cascade). `AccountTests`. |
| Helpers | The `Helper` role (policy `Describe`) reaches only the item list, the item form, "Add many photos", the preview and the generated pictures under `/admin/media` (not the original). Everything else under `/Admin` needs `ManageArchive` (curator or admin) or `Administer`. A helper only gets draft items, in the list, the form, the preview and the pictures, never published, submitted, rejected or withdrawn ones: what visitors see changes only through a curator, and no contribution or contributor name or email reaches a helper (the contribution is not even loaded). The start page counts, the "already in the archive" file check and the reference-number check show a helper drafts only. Publishing, unpublishing, accepting, rejecting, deleting, withdrawing and removing a photo are refused with 403 on the server, not only hidden. Accepted: a helper can read "received from" and the internal notes of the items they open; the handbook says so. `HelperTests` (including a test that lists every `/Admin` address a helper can reach), `AccountTests`. |
| Import | Only curators (the `/Admin` policy). The sheet and ZIP are kept in `import-staging` on the media volume, which is never served by path, for a day at most. A sheet is read as strict UTF-8, at most 20 MB and 100,000 rows; a ZIP at most 4 GB and 200,000 entries; every entry is counted as it is unpacked into a temporary file, and a name inside it is never used in a path. A folder to import from is chosen from a listing of `import/`, links and hidden files are skipped. Files go through the same checks as an upload. One import at a time. Everything imported is a draft; the activity log records each item and the import, never the spreadsheet or the contributors' details. `ImportTests`. |
| PDF files | Only curators can add a PDF; contribution links refuse it. A PDF is recognised by `%PDF-` and read by poppler (`pdfinfo`, `pdftoppm`), a large C++ parser, so it runs as separate processes, never inside the app: each call has a time limit (`Uploads:PdfTimeoutSeconds`, 60) and is killed with its children when it takes longer, the size of the drawn picture is set by us with `-scale-to` whatever size the page claims, at most 300 pages are drawn, and no part of the file or its name reaches a command line (arguments are passed as a list, the file is copied to a random name in an owner-only temporary folder that is removed afterwards). Pages are served only for published items; the PDF stays private. Accepted: a hostile PDF made by a curator could still exploit poppler, which runs with the app's rights in the container; build with `WITH_PDF=false` to remove it. `poppler-utils` comes from the distribution at build time and is not pinned to a version, so a rebuild of the same commit can ship another poppler (accepted; the base image digest is pinned). The text of a PDF (`pdftotext`, same limits, control characters removed, at most 200,000 characters) is only matched by search, never shown, and it is in the index only while the item is not in the bin and the PDF is not in the bin; a draft is found only by curators, as before. The preview queue is single, so a very long PDF delays other previews (at most 60 s per page); copies of a PDF left by a stopped app are removed at the next start. |
Expand Down
3 changes: 2 additions & 1 deletion src/Commonage.Web/Audit/AuditText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public static class AuditText
AuditAction.ContributionLinkChanged => localizer["Changed the contribution link"],
AuditAction.AccountCreated => localizer["Created the account"],
AuditAction.AccountRoleChanged => localizer["Changed the account's role"],
AuditAction.AccountNameChanged => localizer["Changed the name of an account"],
AuditAction.AccountDisabled => localizer["Disabled the account"],
AuditAction.AccountEnabled => localizer["Enabled the account"],
AuditAction.AccountDeleted => localizer["Deleted the account"],
Expand Down Expand Up @@ -93,7 +94,7 @@ or AuditAction.VisitorNoteReceived or AuditAction.VisitorNoteHandled or AuditAct
AuditAction.CollectionCreated or AuditAction.CollectionChanged or AuditAction.CollectionMoved
or AuditAction.CollectionDeleted => AuditKind.Collections,
AuditAction.TagChanged or AuditAction.TagsMerged or AuditAction.TagDeleted or AuditAction.UnusedTagsDeleted => AuditKind.Tags,
AuditAction.AccountCreated or AuditAction.AccountRoleChanged or AuditAction.AccountDisabled or AuditAction.AccountEnabled
AuditAction.AccountCreated or AuditAction.AccountRoleChanged or AuditAction.AccountNameChanged or AuditAction.AccountDisabled or AuditAction.AccountEnabled
or AuditAction.AccountDeleted or AuditAction.SetupLinkCreated or AuditAction.PasswordChanged
or AuditAction.TwoFactorEnabled or AuditAction.TwoFactorDisabled or AuditAction.TwoFactorTurnedOff
or AuditAction.RecoveryCodesCreated or AuditAction.RecoveryCodeUsed => AuditKind.Accounts,
Expand Down
8 changes: 8 additions & 0 deletions src/Commonage.Web/Data/CommonageDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class CommonageDbContext(DbContextOptions<CommonageDbContext> options)
public DbSet<ArchiveItem> ArchiveItems => Set<ArchiveItem>();
public DbSet<MediaFile> MediaFiles => Set<MediaFile>();
public DbSet<ItemFileText> ItemFileTexts => Set<ItemFileText>();
public DbSet<StaffProfile> StaffProfiles => Set<StaffProfile>();
public DbSet<Tag> Tags => Set<Tag>();
public DbSet<ContributionLink> ContributionLinks => Set<ContributionLink>();
public DbSet<Contribution> Contributions => Set<Contribution>();
Expand Down Expand Up @@ -132,6 +133,13 @@ protected override void OnModelCreating(ModelBuilder builder)
.OnDelete(DeleteBehavior.Cascade);
});

builder.Entity<StaffProfile>(profile =>
{
profile.HasKey(p => p.UserId);
profile.Property(p => p.DisplayName).HasMaxLength(StaffProfile.DisplayNameMaxLength);
profile.HasOne<IdentityUser>().WithOne().HasForeignKey<StaffProfile>(p => p.UserId).OnDelete(DeleteBehavior.Cascade);
});

builder.Entity<ItemFileText>(text =>
{
text.HasKey(t => t.ArchiveItemId);
Expand Down
Loading
Loading