Finbuckle.MultiTenant
Finbuckle.MultiTenant copied to clipboard
Option to ignore specific routes and static files
When working with a SPA approach I have a few common endpoints used for everyone and per tenant endpoints using route strategy.
Is there any way to ignore the tenant check for specific routes or all static files?
Hi @DeeJayTC
For files if you place UseStaticFiles
before UseMultiTenant
regular files should not be affected. However there currently isn't a built in way to prevent the multitenant middleware from running otherwise. You could create a custom MultiTenantStrategy
to do that, but I think this is an excellent idea for a new feature.
Yea, especially when you use the dpa middleware its constantly looking up tenant from the hot module replacement checks , websocket connections etc, too.
Could you maybe, to make it easier add something that allows to say:
UseRouteStrategyExplicit( RoutesThatShouldCheckTenant )
Any other route is ignored?
Or else any route without the __ Tenant __ is ignored automatically per option?
SPA middleware...not dpa :)
In a similar place here with a SPA application and it looks very chatty on the server end checking finbuckle tenancy unnecessarily. Will try and implement a custom strategy but will also greatly welcome the proposed enhancement.
Thanks for the input!
It's funny because in ASP.NET Core 2.1 you actually can set a different route for the strategy but then in ASP.NET Core 2.2 they changed to "Endpoint" routing which overall is better but has this one issue.
In general the tenant strategy is fast but the tenant store check can be slow. So with that in mind I have a few ideas. Tell me what you think:
- Exception list - Have a way to tell the middleware to ignore certain identifiers if it finds them. E.g. if it thinks it finds a tenant identifier of 'spa_folder' then just treat it like a null and don't look into the store, etc.
- Add events to the middleware like with authentication so you can register a function for events like
OnTenantIdentifierFound
, check the identifier it found, and tell it to ignore it by setting a result toHandled
or something like that.
I plan to do both, hopefully #1 in the next release.
Thanks for the input!
It's funny because in ASP.NET Core 2.1 you actually can set a different route for the strategy but then in ASP.NET Core 2.2 they changed to "Endpoint" routing which overall is better but has this one issue.
In general the tenant strategy is fast but the tenant store check can be slow. So with that in mind I have a few ideas. Tell me what you think:
- Exception list - Have a way to tell the middleware to ignore certain identifiers if it finds them. E.g. if it thinks it finds a tenant identifier of 'spa_folder' then just treat it like a null and don't look into the store, etc.
- Add events to the middleware like with authentication so you can register a function for events like
OnTenantIdentifierFound
, check the identifier it found, and tell it to ignore it by setting a result toHandled
or something like that.I plan to do both, hopefully #1 in the next release.
In my case Finbuckle middleware is running even when the React app is being loaded. I think that's partly due to poor architecture my end. I was thinking I will separate the SPA to load from a different project where multitenancy is not required and then just run the backend APIs and persistence with multitenancy.
Update: Implemented the above and it now works better.
@hbermani Excellent!