Skip to content

feat(audit_log): stamp entries with tenant, tenant column/filter (#372) [stack 7/11] - #391

Merged
antosubash merged 9 commits into
tenancy/06-keycloakfrom
tenancy/07-audit-log
Oct 1, 2026
Merged

antosubash merged 9 commits into
tenancy/06-keycloakfrom
tenancy/07-audit-log

Conversation

@antosubash

Copy link
Copy Markdown
Owner

Closes #372. Stack 7/11 of the tenancy-adoption series (base: #390).

What

  • AuditEntry gets a nullable, indexed tenant_id, stamped in capture.py from current_tenant_id. NULL means a platform action. There is no MultiTenantMixin: platform-table writes have no tenant, and strict mode would raise inside the flush.
  • A (tenant_id, created_at) composite index. Migration a7c2e91d4b58 on the audit_log chain; existing rows stay NULL.
  • /admin/audit-log stays platform-wide:
    • A tenant column and a tenant filter (All / Platform / tenant ids), on the API, the export and the browse view.
    • The CSV gains a tenant_id column.
    • The dropdown shows tenant ids, not names, because audit_log doesn't depend on tenants.
  • Tenant roles get 403 on the list and export endpoints.

Tests

  • test_tenancy.py covers:
    • stamping under tenant_context
    • NULL for platform writes and all_tenants()
    • the list and export filters
    • 403 for all three tenant roles
  • make test-py: 3382 passed. make test-js: 463 passed. make lint and make doctor are clean.

https://claude.ai/code/session_01F8RiTBUJQnZmSq56qReZeV

… column/filter (#372)

AuditEntry gets a nullable, indexed tenant_id (NULL = platform action) stamped
from current_tenant_id in the capture callback, plus a (tenant_id, created_at)
index. Deliberately not MultiTenantMixin: platform writes have no tenant and
strict mode would raise inside the flush. /admin/audit-log stays platform-wide
with a tenant column and filter on browse, API and CSV export.

Claude-Session: https://claude.ai/code/session_01F8RiTBUJQnZmSq56qReZeV
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Deploying simple-module-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1caa633
Status: ✅  Deploy successful!
Preview URL: https://d3eef324.simple-module-python.pages.dev
Branch Preview URL: https://tenancy-07-audit-log.simple-module-python.pages.dev

View logs

…nal (review of #372)

- BrowseEmpty showed the raw __platform__ sentinel in its filter summary;
  map it to audit_log.filters.tenant_platform (Browse passes the value).
- The CSV export appends tenant_id after changes instead of inserting it
  before, so positional consumers keep finding every old column.
- Document that a platform admin's actions are attributed to their active
  organisation when one is active.

Claude-Session: https://claude.ai/code/session_01F8RiTBUJQnZmSq56qReZeV
@antosubash
antosubash added this pull request to stack #397 October 1, 2026 16:14
@antosubash
antosubash marked this pull request as ready for review October 1, 2026 16:16
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-10-01T16:19:58.444332Z cec6c5e Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@antosubash
antosubash merged commit a691d3b into main Oct 1, 2026
13 checks passed
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_log: tag AuditEntry with tenant_id and tenant-scope the browse/export screens

1 participant