fix: enforce tenant isolation on multi-tenant session and login#11
Merged
fix: enforce tenant isolation on multi-tenant session and login#11
Conversation
Session cookies shared across *.unitae.app subdomains allowed a user authenticated on one congregation's subdomain to access their data from another congregation's subdomain. The login form also accepted any valid credentials regardless of subdomain. - Add resolveCongregationFromRequest() to resolve congregation from the request hostname (subdomain slug or custom domain) - Validate tenant match in verifySession(), destroying the session and redirecting to /login on mismatch - Scope validateCredentials() to the subdomain's congregation so login rejects accounts belonging to other tenants - Validate existing sessions in the login loader before auto-redirecting - Add /congregation-not-found error page for unknown subdomains - All checks are no-ops in single-tenant mode (MULTI_TENANT !== 'true')
This was referenced Apr 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
*.unitae.appsubdomains allowed cross-tenant data access. A user authenticated on one congregation's subdomain could navigate to another subdomain and see their own congregation's data there.resolveCongregationFromRequest()to resolve the congregation from the request hostname (subdomain slug or custom domain), and validates it against the session inverifySession()and the login flow.validateCredentials()to the subdomain's congregation so login rejects accounts belonging to other tenants (shows generic "Email ou mot de passe invalide" — no information leakage)./congregation-not-founderror page for unknown subdomains.MULTI_TENANT !== 'true').Test plan
fake-slug.unitae.app→ should see "Assemblée non trouvée" error pageMULTI_TENANTunset) → no behavioral changepnpm test:unit— all 316 tests passpnpm test:typecheck— cleanpnpm test:lint— clean