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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ version may change things that need attention when updating, and these notes say

### For curators

- A published item can have an **embargo**: set "Public from" on the item, and until the start of that day (in the archive's time
zone) it is as hidden as a draft, everywhere, including its pictures. Lists, feeds and the start page put the item where it
belongs on the day it opens. Exports of published items leave out items still under embargo (export format version 8).
- "What visitors get" and "Public from" can be set for many items at once from the item list, and the list can show only items
shown as a record only or still under embargo. The collection cover choice says which photos visitors do not see.
- An item can be shown as a **record only**: visitors get its title, description, date, place and credit, but no picture, page
image or recording, and search does not find what its PDFs or captions say. Choose "What visitors get" on the item's page;
the item list shows a "Record only" badge. Exports of published items leave out the files of such items; the full export
Expand Down
2 changes: 1 addition & 1 deletion docs/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ none of them most, and null if never chosen), and `otherContentLanguages`, separ
`rejectedKeptMonths` are how long records are kept (null for always), and each item's `rejectedOrWithdrawnAt` is when that time
started for it.

`archive.json` has `"format": "commonage-export"` and `"version": 7`. Version 7 added `mediaLevel` to each item (`Everything` or `RecordOnly`). In an export of published items, the files of a record-only item are left out, because visitors never get them. Version 6 added `pageCount` to each file (for a PDF, how many pages have a preview; the page pictures and the text read from a PDF for search are left out, because they can be made again from the file). Version 5 added `helpWanted` to each item, also in an export of published items, because the page "Can you help?" shows it. Version 4 added `tags`, each with its `name` and `kind`
`archive.json` has `"format": "commonage-export"` and `"version": 8`. Version 8 added `publicFrom` to each item (the day an embargo ends, or empty); an export of published items has no item that is still embargoed. Version 7 added `mediaLevel` to each item (`Everything` or `RecordOnly`). In an export of published items, the files of a record-only item are left out, because visitors never get them. Version 6 added `pageCount` to each file (for a PDF, how many pages have a preview; the page pictures and the text read from a PDF for search are left out, because they can be made again from the file). Version 5 added `helpWanted` to each item, also in an export of published items, because the page "Can you help?" shows it. Version 4 added `tags`, each with its `name` and `kind`
(`Topic`, `Place` or `Person`); items still list their tags by name. Each collection also has its `position` among the others,
the `sort` of its items (`RecentlyAdded`, `OldestFirst` or `NewestFirst`) and `coverFileId`, the `id` of the file chosen as its
cover, or null when none is chosen or that file is not in the export. Items also have `notes`, the messages visitors sent through
Expand Down
2 changes: 1 addition & 1 deletion docs/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ vulnerability, see [SECURITY.md](../SECURITY.md).

| Area | Measure |
|---|---|
| Access | Public pages and public image addresses read only from published items (`VisibleItems`, `VisibleMedia`). 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. An item shown as a record only (`MediaLevel.RecordOnly`) gives visitors no file, thumbnail, cover, link-preview picture or PDF-text match; `VisibleMedia` and `Visibility.ItemWithMedia` are the one place that decides, and `ItemFilter.SearchAllFileText` is off unless a curator searches. 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. |
| Access | Public pages and public image addresses read only from published items (`VisibleItems`, `VisibleMedia`). 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. An item under embargo (`PublicFrom` in the future, in the archive's time zone) is as hidden as a draft: it passes through `VisibleItems`/`VisibleMedia` with the day as a parameter, tested with a clock. Feeds and the sitemap are cached for ten minutes, so an item can show up to ten minutes late or stay that long after it is unpublished. An item shown as a record only (`MediaLevel.RecordOnly`) gives visitors no file, thumbnail, cover, link-preview picture or PDF-text match; `VisibleMedia` and `Visibility.ItemWithMedia` are the one place that decides, and `ItemFilter.SearchAllFileText` is off unless a curator searches. 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`. |
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 @@ -25,6 +25,7 @@ public static class AuditText
AuditAction.ItemPublished => localizer["Published the item"],
AuditAction.ItemUnpublished => localizer["Unpublished the item"],
AuditAction.ItemMediaLevelChanged => localizer["Changed what visitors get of the item"],
AuditAction.ItemPublicFromChanged => localizer["Changed the date from which the item is public"],
AuditAction.ItemFieldRestored => localizer["Restored an earlier text of the item"],
AuditAction.ItemDeleted => localizer["Deleted the item for good"],
AuditAction.ItemMovedToBin => localizer["Moved the item to the bin"],
Expand Down Expand Up @@ -83,7 +84,7 @@ public static class AuditText

public static AuditKind KindOf(AuditAction action) => action switch
{
AuditAction.ItemCreated or AuditAction.ItemChanged or AuditAction.ItemFieldRestored or AuditAction.ItemPublished or AuditAction.ItemUnpublished or AuditAction.ItemMediaLevelChanged
AuditAction.ItemCreated or AuditAction.ItemChanged or AuditAction.ItemFieldRestored or AuditAction.ItemPublished or AuditAction.ItemUnpublished or AuditAction.ItemMediaLevelChanged or AuditAction.ItemPublicFromChanged
or AuditAction.ItemDeleted or AuditAction.ItemMovedToBin or AuditAction.ItemRestored or AuditAction.ItemPurged
or AuditAction.ItemMovedToBinAfterKeptTime or AuditAction.ItemsImported => AuditKind.Items,
AuditAction.PhotosAdded or AuditAction.PhotosArranged or AuditAction.PhotoDeleted or AuditAction.PhotoMovedToBin
Expand Down
9 changes: 6 additions & 3 deletions src/Commonage.Web/Data/CommonageDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Commonage.Web.Data;

public class CommonageDbContext(DbContextOptions<CommonageDbContext> options)
public class CommonageDbContext(DbContextOptions<CommonageDbContext> options, TimeProvider? clock = null)
: IdentityDbContext<IdentityUser>(options), IDataProtectionKeyContext
{
public DbSet<Collection> Collections => Set<Collection>();
Expand Down Expand Up @@ -46,10 +46,13 @@ public class CommonageDbContext(DbContextOptions<CommonageDbContext> options)
public const string FoldFunction = "commonage_fold";

/// <summary>Items the public may see. Every public page must start from this query.</summary>
public IQueryable<ArchiveItem> VisibleItems => ArchiveItems.Where(Visibility.Item);
public IQueryable<ArchiveItem> VisibleItems => ArchiveItems.Where(Visibility.Item(Today));

/// <summary>Today in the archive's time zone: what an embargo is compared with.</summary>
public DateOnly Today => Dates.Today((clock ?? TimeProvider.System).GetUtcNow());

/// <summary>Files the public may be given. <c>/media</c> and every cover or first photo start from this.</summary>
public IQueryable<MediaFile> VisibleMedia => MediaFiles.Where(Visibility.Media);
public IQueryable<MediaFile> VisibleMedia => MediaFiles.Where(Visibility.Media(Today));

/// <summary>Items in the bin. Query filters hide them from every other query, see <see cref="OnModelCreating"/>.</summary>
public IQueryable<ArchiveItem> BinnedItems => ArchiveItems.IgnoreQueryFilters().Where(i => i.DeletedAt != null);
Expand Down
Loading