dazinator / Dotnettency

Mutlitenancy for dotnet applications
MIT License
111 stars 23 forks source link

Blazor support - cascading TenantInfo parameter #49

Open dazinator opened 5 years ago

dazinator commented 5 years ago

See cascading parameter concept in Blazor : https://github.com/dotnet-presentations/blazor-workshop/blob/master/docs/05-authentication-and-authorization.md

Dotnettency could offer a similar cascading parameter to allow access to the current TTenant information retrieved from the server.

dazinator commented 5 years ago

Support for this could be added to a Donettency.Spa.Blazor package. Similar to CascadingAuthenticationState component, you could use CascadingTenantState component. This component would be configured in startup.cs to obtain current tenant information (generic TTenantInfo) from either:

  1. GET request to some configurable path that returns TTenantInfo as Json.
  2. Http client RequestDelegatingHandler that can intercept the response from the server and deserialise TTenantInfo from a header in the response containing Json.

2 is a stretch goal. Awaiting the cascaded Task<TenantInfo> in blazor , would cause a request to the server using option 1 if the task hasn't run before. Task is reused so this would only happen once unless invalidated.