Skip to content

Audit log as a grantable account-level permission (#45) - #59

Merged
CaYatur merged 1 commit into
mainfrom
feat/audit-grantable-perm
Jul 24, 2026
Merged

Audit log as a grantable account-level permission (#45)#59
CaYatur merged 1 commit into
mainfrom
feat/audit-grantable-perm

Conversation

@CaYatur

@CaYatur CaYatur commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Closes #45. First of the UX & access pass.

Why

The web audit endpoint was owner-only because entries carry player IPs (personal data). That meant a trusted co-admin couldn't see the log at all. This adds an account-level canAudit grant (distinct from the per-server RBAC scopes, since audit is global) so an owner can hand out audit access without full ownership.

Changes

  • auth.tscanAudit on the stored user and AuthUser; new setUserAudit(id, canAudit) returning the username for attribution. Migrates cleanly (?? false) for a users.json written before this.
  • server.ts/api/audit gate becomes owner || canAudit; /api/me now reports canAudit so the panel can reveal the tab.
  • IPC web:user-audit — desktop-only, like the rest of user management, so "owner-only to set" holds. Deliberately not a web route: a web endpoint would let a settings-scoped user self-grant access to personal-data IPs. The grant and the revoke are themselves audited (source: panel, action: user.audit-grant).
  • WebPanelView — an "audit log" checkbox in the (non-owner) permissions modal; only writes when it actually changed, so it doesn't log a spurious grant on every perms save.
  • panelHtml — the Audit tab shows when owner || canAudit (myCanAudit set from both the login response and /api/me).
  • en/tr strings.

Verify

  • typecheck, build — pass.
  • MSMS_SMOKE_WEB PASS: a fresh non-owner (auditor_t) is 403, 200 after the grant (with /api/me carrying the flag), 403 again after revoke. The existing friend_t → 403 audit test is untouched (dedicated user, no state leak).
  • Panel tab visibility checked in a real browser engine across all four combinations: hidden by default, hidden for a plain user, visible for a granted non-owner, visible for an owner.

Audit log as a grantable account-level permission (#45)

The web audit endpoint was owner-only (entries carry player IPs). Let an
owner grant a trusted co-admin read access without making them an owner,
via an account-level flag distinct from the per-server RBAC scopes.

- auth.ts: `canAudit` on the stored user + AuthUser; new setUserAudit(id,
  canAudit) returning the username for attribution. Migrates cleanly
  (`?? false`) for users.json written before this.
- server.ts: /api/audit gate becomes `owner || canAudit`; /api/me now
  reports canAudit so the panel can reveal the tab.
- IPC web:user-audit (desktop-only, like the rest of user management —
  so "owner-only to set" holds; NOT exposed as a web route, which would
  let a settings-scoped user self-grant). The grant AND revoke are
  themselves audited (source panel, action user.audit-grant).
- WebPanelView: an "audit log" checkbox in the (non-owner) permissions
  modal; only writes when it actually changed.
- panelHtml: Audit tab shows when `owner || canAudit` (myCanAudit set from
  both the login response and /api/me).
- en/tr strings.

Verify: MSMS_SMOKE_WEB — a fresh non-owner is 403, 200 after the grant
(with /api/me carrying the flag), 403 again after revoke; the existing
friend_t 403 test is untouched (dedicated auditor_t user). Panel tab
visibility checked in a real browser engine across all four role/flag
combinations.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@
Copilot AI review requested due to automatic review settings July 24, 2026 16:03
@CaYatur
CaYatur merged commit b714f91 into main Jul 24, 2026
1 check passed
@CaYatur
CaYatur deleted the feat/audit-grantable-perm branch July 24, 2026 16:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Audit as a grantable permission (not owner-only)

2 participants