advancedScenario Questions

Scenario 29: A SaaS product wants to guarantee that Company A's users can never see Company B's data, even if both are on the same shared infrastructure.

This calls for tenant isolation enforced through the token itself: embed a tenant_id claim in the JWT/OIDC token at issuance (e.g., a dedicated Keycloak realm per tenant, or a custom claim mapper), and enforce it at BOTH the authorization layer (every query/service method scoped by tenant_id, similar to per-user ownership checks) and, ideally, at the database layer (row-level security or separate schemas) as defense-in-depth beyond just the application code.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to Scenario 30: Your team wants to migrate everyone from BCrypt to Argon2 without forcing a mass password reset across the whole user base.← Back to all Spring Security questions