Skip to content

fix(audit): enforce tenant scoping for audit log queries#309

Merged
Baskarayelu merged 2 commits into
CredenceOrg:mainfrom
kryputh:fix/auditlog-tenant-scope-fresh
Apr 26, 2026
Merged

fix(audit): enforce tenant scoping for audit log queries#309
Baskarayelu merged 2 commits into
CredenceOrg:mainfrom
kryputh:fix/auditlog-tenant-scope-fresh

Conversation

@kryputh
Copy link
Copy Markdown
Contributor

@kryputh kryputh commented Apr 26, 2026

Prevent cross-tenant leakage by enforcing tenant scoping in audit log repositories and routes.

Key changes:

  • Updated AuditLogService to require tenantId for all logging and retrieval operations.
  • Implemented tenant-aware filtering in PostgresAuditLogsRepository and InMemoryAuditLogsRepository.
  • Refactored all administrative services (Webhooks, Replay, Policy, Members, Impersonation) to pass the authenticated user's tenantId to the audit trail.
  • Enforced strict scoping in routes by passing the tenantId from the authenticated request context.
  • Fixed potential ReferenceError in admin route catch blocks by ensuring the next parameter is correctly defined and utilized.
  • Verified isolation logic with updated unit tests.

Scoping Policy:

  • Standard Admin: Restricted strictly to their own tenantId.
  • Super Admin: Can view all logs or filter by specific tenant if allowSuperScope is explicitly enabled.

Closes #228

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 26, 2026

@kryputh Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Baskarayelu Baskarayelu merged commit 47179e4 into CredenceOrg:main Apr 26, 2026
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.

[Fresh 2026-04][Backend] Security: enforce tenant scoping on audit log queries

2 participants