Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimizing tenant resolution and routing #1337

Merged
merged 1 commit into from
May 11, 2021
Merged

optimizing tenant resolution and routing #1337

merged 1 commit into from
May 11, 2021

Conversation

sbwalker
Copy link
Member

No description provided.

@sbwalker
Copy link
Member Author

sbwalker commented May 11, 2021

This is a substantial enhancement to the tenant resolution and routing aspects of the framework:

  • consolidated all tenant resolution logic in a new TenantManager infrastructure class ( TenantResolver has been retained for backward compatibility but now relies on TenantManager )
  • performance of tenant resolution logic has been optimized in TenantManager to do less intensive work
  • TenantManager can be injected in any Server workload to get the current Alias ( which includes information about the Alias, Tenant, and Site )
  • TenantManager contains new methods for SetAlias() and SetTenant() which can be used to explicitly set the Alias in situations where there is no HttpContext ( ie. during background processing ) or where more granularity is required ( this replaces the need to interact with SiteState directly ).
  • introduced a new middleware UseTenantResolution which executes very early in the request pipeline and resolves the tenant using TenantManager. It executes directly after the static file middleware so that only dynamic code paths such as Razor/MVC Pages and Web API Controllers are processed
  • UseTenantResolution improves the overall performance by executing the tenant resolution logic only once for each request
  • UseTenantResolution also rewrites the Url to remove the alias prefix so that the request can satisfy standard route matching criteria (ie. if the alias name for the site is "www.site.com/department/committee/group" then the Url would be rewritten to remove "department/committee/group" and produce a standard API Url such as "www.site.com/api/Site" - as the Alias has already been resolved and will be preserved for the duration of the request)
  • all Services and Controllers have been migrated to use a more standard route template (ie. "api/[controller]") which no longer has a requirement to include the AliasId as the first path segment. Routes are now prefixed with the actual alias name value so that they are more intuitive and human readable ( the old route template pattern is still supported for backward compatibility purposes )
  • Login/Logout pages also now utilize standard route templates without an AliasId prefix
  • ContentUrl now utilizes a standard route template without an AliasId prefix
  • _Host.cshtml has been modified to remove the custom tenant resolution logic and rely on UseTenantResolution middleware
  • cross-alias API calls are unreliable due to the fact that authentication does not flow across domain boundaries, so use of this approach has been deprecated. This only affected Site Management which was previously attempting to allow host users to Edit/Delete sites - this functionality has been retained via Site Settings which is a more reliable approach.

These changes are intended to be backward compatible with all of the standard/known development patterns for external modules.

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.

1 participant