From 347d727d6e1c66be95e6517d472758aca8ce164a Mon Sep 17 00:00:00 2001 From: piquel Date: Wed, 4 Nov 2026 14:20:08 +0100 Subject: [PATCH 1/2] fix(history): an administrator's views stay out of the owner's history A view may be a misclick or a confidential inquiry. The owner's security history shows changes, each with its reason; only the audit keeps views. --- README.md | 3 ++- apps/auth-service/src/history/mod.rs | 3 +-- apps/auth-service/src/history/tests.rs | 5 +++-- crates/common/src/events/mod.rs | 10 ++++------ crates/ui/src/settings/timeline.rs | 1 - docs/architecture/database-crate.md | 5 ++++- docs/architecture/surfaces.md | 3 ++- 7 files changed, 16 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 8a258363e..3e94f989b 100644 --- a/README.md +++ b/README.md @@ -278,7 +278,8 @@ just auth account alice apps remove --reason "Impersonating app" owner: passkeys, social identities, email addresses, sessions, connected apps and the security history, with the owner's own operations. It never adds a way to sign in or an address. Every change needs `--reason`, which the owner sees in - their history; reads are recorded as views. See + their history; reads are recorded as views, which only the audit shows, not the + owner. See [surfaces.md](docs/architecture/surfaces.md#changing-an-account-on-its-owners-behalf) for what is shared. - `user recover` is for an owner who lost every passkey. It signs the account diff --git a/apps/auth-service/src/history/mod.rs b/apps/auth-service/src/history/mod.rs index f7d6acd72..c8be44708 100644 --- a/apps/auth-service/src/history/mod.rs +++ b/apps/auth-service/src/history/mod.rs @@ -196,7 +196,7 @@ impl Activity { /// feed agree, as far as a count by kind can: a refresh grant's revocation /// is left out, since the history shows only a replay's, and a session's /// expiry is counted, since the history hides only that reason. - const SECURITY: [&'static str; 29] = [ + const SECURITY: [&'static str; 28] = [ "account_created", "signed_in", "session_revoked", @@ -214,7 +214,6 @@ impl Activity { "code_replayed", "account_disabled", "account_enabled", - "account_viewed", "administrator_granted", "administrator_revoked", "handle_changed", diff --git a/apps/auth-service/src/history/tests.rs b/apps/auth-service/src/history/tests.rs index f4b9a9dce..ee88c4123 100644 --- a/apps/auth-service/src/history/tests.rs +++ b/apps/auth-service/src/history/tests.rs @@ -140,7 +140,8 @@ async fn pages_hold_only_the_callers_entries() { user_id: bob.user_id, session_id: bob.session_id, }, - vec![DomainEvent::AccountViewed {}], + // The view is hidden; the change shows. + vec![DomainEvent::AccountViewed {}, DomainEvent::AccountEnabled {}], ) .await; harness @@ -166,7 +167,7 @@ async fn pages_hold_only_the_callers_entries() { ); assert_eq!( (&entries[1]["kind"], &entries[1]["actor"]), - (&json!("account.viewed"), &json!("admin")) + (&json!("account.enabled"), &json!("admin")) ); assert_eq!(entries[2]["kind"], "passkey.renamed"); assert_eq!(entries[2]["actor"], "account"); diff --git a/crates/common/src/events/mod.rs b/crates/common/src/events/mod.rs index 69f020130..aa60fcd7a 100644 --- a/crates/common/src/events/mod.rs +++ b/crates/common/src/events/mod.rs @@ -174,6 +174,7 @@ pub enum DomainEvent { /// A disabled account was reactivated. AccountEnabled {}, /// An administrator viewed the account's details, which hold personal data. + /// Kept for the audit only: the owner's history shows changes, not reads. AccountViewed {}, /// The account became an administrator. AdministratorGranted {}, @@ -642,7 +643,6 @@ impl DomainEvent { // The reason is written for administrators and may name other people. Self::AccountDisabled { .. } => HistoryEntry::AccountDisabled, Self::AccountEnabled {} => HistoryEntry::AccountEnabled, - Self::AccountViewed {} => HistoryEntry::AccountViewed, Self::AdministratorGranted {} => HistoryEntry::AdministratorGranted, Self::AdministratorRevoked {} => HistoryEntry::AdministratorRevoked, Self::HandleChanged { .. } => HistoryEntry::HandleChanged, @@ -686,6 +686,9 @@ impl DomainEvent { | Self::DeliveryCancelled { .. } | Self::SigningKeyChanged { .. } | Self::AuditHistoryPruned { .. } + // A read may be a misclick or a confidential inquiry; the owner sees + // changes, each with its reason, not what an administrator looked at. + | Self::AccountViewed {} // Nobody can read the history of an account that no longer exists. | Self::AccountPurged {} => return None, }) @@ -800,9 +803,6 @@ pub enum HistoryEntry { /// The account was reactivated. #[serde(rename = "account.enabled")] AccountEnabled, - /// An administrator viewed the account's details. - #[serde(rename = "account.viewed")] - AccountViewed, /// The account became an administrator. #[serde(rename = "administrator.granted")] AdministratorGranted, @@ -885,7 +885,6 @@ impl HistoryEntry { | Self::TokenReused | Self::AccountDisabled | Self::AccountEnabled - | Self::AccountViewed | Self::AdministratorGranted | Self::AdministratorRevoked | Self::HandleChanged @@ -928,7 +927,6 @@ impl HistoryEntry { | Self::TokenReused | Self::AccountDisabled | Self::AccountEnabled - | Self::AccountViewed | Self::AdministratorGranted | Self::AdministratorRevoked | Self::HandleChanged diff --git a/crates/ui/src/settings/timeline.rs b/crates/ui/src/settings/timeline.rs index 6ac1ecc4e..1246d5411 100644 --- a/crates/ui/src/settings/timeline.rs +++ b/crates/ui/src/settings/timeline.rs @@ -187,7 +187,6 @@ impl HistoryRow<'_> { } HistoryEntry::AccountDisabled => "Account disabled".to_owned(), HistoryEntry::AccountEnabled => "Account re-enabled".to_owned(), - HistoryEntry::AccountViewed => "Account details viewed".to_owned(), HistoryEntry::AdministratorGranted => "Administrator rights granted".to_owned(), HistoryEntry::AdministratorRevoked => "Administrator rights removed".to_owned(), HistoryEntry::HandleChanged => "Handle changed".to_owned(), diff --git a/docs/architecture/database-crate.md b/docs/architecture/database-crate.md index a92747486..511efe7bf 100644 --- a/docs/architecture/database-crate.md +++ b/docs/architecture/database-crate.md @@ -489,7 +489,10 @@ the query itself excludes other accounts. `DomainEvent::history_entry` decides what a user sees. It names every variant, under `#[deny(clippy::wildcard_enum_match_arm)]`, so a new event cannot be added without that decision. Ceremonies, rejected attempts, token bookkeeping and invitations -are hidden; admin and CLI actions show with the kind of actor, never the operator. +are hidden; admin and CLI changes show with the kind of actor, never the operator. +An administrator's views of the account are hidden too: a read may be a misclick +or a confidential inquiry, so the owner sees changes, each with its reason, and +only the audit keeps the views. `POST /account/history/{event_id}/report` reports an entry the user caused as not theirs. One transaction records `CompromiseReported`, ends the account's other diff --git a/docs/architecture/surfaces.md b/docs/architecture/surfaces.md index 5ad00e8b8..da5fc57c9 100644 --- a/docs/architecture/surfaces.md +++ b/docs/architecture/surfaces.md @@ -145,7 +145,8 @@ When an administrator or operator acts: each event as personal data, and the owner sees it in their security history, next to "By a Piquel administrator". - Events record the administrator or operator as their actor. A page's reads are - recorded as one view of the account, as `user show` is. + recorded as one view of the account, as `user show` is. The owner's history + leaves views out: it shows changes, with their reasons, not reads. - An administrator may not change another administrator's account: it is refused before waiting for the account lock and again under it. A change checks the administrator's rights, session and passkey confirmation once more before it From 134a1aae5d82ebad9ad02b79168adaf5350e2556 Mon Sep 17 00:00:00 2001 From: piquel Date: Wed, 4 Nov 2026 14:25:34 +0100 Subject: [PATCH 2/2] style(history): format the view test --- apps/auth-service/src/history/tests.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/auth-service/src/history/tests.rs b/apps/auth-service/src/history/tests.rs index ee88c4123..3142c3166 100644 --- a/apps/auth-service/src/history/tests.rs +++ b/apps/auth-service/src/history/tests.rs @@ -141,7 +141,10 @@ async fn pages_hold_only_the_callers_entries() { session_id: bob.session_id, }, // The view is hidden; the change shows. - vec![DomainEvent::AccountViewed {}, DomainEvent::AccountEnabled {}], + vec![ + DomainEvent::AccountViewed {}, + DomainEvent::AccountEnabled {}, + ], ) .await; harness