Best approach for handling 100+ tenant RedirectUris under a single Client ID #638
Replies: 1 comment
|
The most secure solution would be to assign a separate client ID per tenant, especially if you want to isolate scopes or sessions per tenant (e.g. when sending logout notifications). A single client ID for all tenant instances could work, but there are a few things to keep in mind. I'll try and answer your questions. 1. Security: can a redirect be switched to another tenant's domain?In short: no. IdentityServer checks the The real risk here, is that all your tenant apps share one client, so they all accept the same tokens:
If your tenants need to be isolated from each other, you need to add that isolation yourself (see Binding tokens to a tenant below) or make sure the client has a separate client ID for each tenant. 2. PerformanceA few hundred redirect URIs compared by exact string match costs very little in terms of performance, especially when client store caching is enabled. Performance should likely not weigh in your decision. 3. AlternativesCustom IRedirectUriValidatorA custom IRedirectUriValidator that checks the requested URI against your tenant registry is a reasonable approach. It isn't any safer or faster than a large list, but it keeps one source of truth for tenant hosts, which you'll likely want for the topics below too. Keep matching exact (scheme, host and path), with no wildcards or prefix matching. SpacesSpaces is our solution for making IdentityServer itself multi-tenant aware. From what you've described, the multi-tenancy is on the client side (one app deployed per tenant), with a single IdentityServer serving them all. That setup doesn't necessarily need Spaces. It becomes relevant if IdentityServer also needs per-tenant behavior, such as separate users, signing keys, configuration or branding per tenant. If that's the case, let us know more about your IdentityServer setup and we can look at it together. For lighter-weight scenarios, a tenant hint passed via Logout across 100+ tenantsThe Client model has a single IdentityServer builds front- and back-channel logout notifications in
Binding tokens to a tenantTo prevent the cross-tenant reuse described in question 1, consider parameterized scopes, such as The important part is that the server must enforce it. The client chooses which scopes to request, so the scope only binds anything if IdentityServer checks it. At minimum, verify that:
On the receiving side:
An alternative is resource isolation using resource indicators, with an API resource per tenant, which puts the tenant in the token's audience. That also works, but means managing a large number of API resources. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Context:
We are running a multi-tenant application where the same web app code is deployed across ~100 distinct instances in IIS. Some tenants share a multi-tenant infrastructure, while others are entirely dedicated with their own separate databases. We are looking to implement Duende IdentityServer to handle OIDC and enable Single Sign-On (SSO) with another upstream service.
we intend to register all 100+ tenant instances under a single global ClientId (e.g., "robo-web").
We are considering grouping all tenant callback domains inside the RedirectUris and PostLogoutRedirectUris arrays for this single client, pulling the list dynamically from a database rather than hardcoding it:
Questions / Points for Discussion
Security & Isolation: Does passing a massive global list of allowed redirect URLs to a single ClientId expose us to cross-tenant token substitution vulnerabilities? If a user initiates a login from ://robo.com but forces the redirect to ://robo.com, will IdentityServer allow it since both domains are "trusted" by the same client?
Performance: What are the performance and memory implications of loading and validating hundreds of custom tenant domains inside the Client object during the token pipeline?
Alternative Solutions: Is implementing a custom IRedirectUriValidator to lazily match the incoming domain against our database a safer and more performant pattern here? Alternatively, does this use case require something like the Duende "Spaces" add-on?
We want to make sure we architect this correctly for security, performance, and compliance with the 10 Client ID license boundary. Any recommendations or best practices from the team would be greatly appreciated!
All reactions