WorkClub Automation
c918f447b2
fix(backend): add TenantDbTransactionInterceptor for RLS with explicit transactions
...
Implements Option D: wraps auto-commit reads in explicit transactions with SET LOCAL.
Handles transaction lifecycle (create→SET LOCAL→execute→commit/dispose).
Uses IDbTransactionInterceptor for EF-managed SaveChanges transactions.
Critical fix for PostgreSQL RLS requiring transaction-scoped context.
2026-03-05 20:43:03 +01:00
WorkClub Automation
3b7db39cc2
fix(backend): update middleware ordering and interceptors for RLS
...
Update TenantValidationMiddleware, Program.cs startup sequence,
SaveChangesTenantInterceptor, and TenantProvider to ensure proper
middleware ordering and tenant context initialization before database access.
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai >
2026-03-05 19:22:21 +01:00
WorkClub Automation
7859e1b3cf
fix(infra): add explicit transaction management to TenantDbConnectionInterceptor for RLS
...
PostgreSQL SET LOCAL only persists within a transaction scope. Added explicit transaction creation if none exists, ensuring tenant context is properly set before queries execute. Fixes tenant isolation for multi-tenant RLS filtering.
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode )
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai >
2026-03-05 16:30:50 +01:00
WorkClub Automation
8d3ac6e64a
Remove transaction check from TenantDbConnectionInterceptor.SetTenantContext
...
Allow SET LOCAL execution for all database commands by removing the transaction check.
EF Core creates implicit transactions for queries, so SET LOCAL works regardless.
This fixes the issue where read operations without explicit transactions were not getting
tenant context set properly, leading to incorrect RLS filtering and data visibility.
2026-03-05 16:08:09 +01:00
WorkClub Automation
1a5d5e8651
style(backend): apply dotnet format whitespace normalization
...
- Applied dotnet format to 24 files in backend/
- Corrects spacing, indentation, and formatting consistency
- No functional changes to code logic
Ultraworked with Sisyphus <https://github.com/code-yeongyu/oh-my-opencode >
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai >
2026-03-05 11:07:19 +01:00
WorkClub Automation
28964c6767
feat(backend): add PostgreSQL schema, RLS policies, and multi-tenant middleware
...
- Add EF Core migrations for initial schema (clubs, members, work_items, shifts, shift_signups)
- Implement RLS policies with SET LOCAL for tenant isolation
- Add Finbuckle multi-tenant middleware with ClaimStrategy + HeaderStrategy fallback
- Create TenantValidationMiddleware to enforce JWT claims match X-Tenant-Id header
- Add tenant-aware DB interceptors (SaveChangesTenantInterceptor, TenantDbConnectionInterceptor)
- Configure AppDbContext with tenant scoping and RLS support
- Add test infrastructure: CustomWebApplicationFactory, TestAuthHandler, DatabaseFixture
- Write TDD integration tests for multi-tenant isolation and RLS enforcement
- Add health check null safety for connection string
Tasks: 7 (PostgreSQL schema + migrations + RLS), 8 (Finbuckle multi-tenancy + validation), 12 (test infrastructure)
2026-03-03 14:32:21 +01:00