[Improvement] Add sub-domain / domain tenancy support
dave-redfern opened this issue · 2 comments
Current version only works with URI / post User auth, a sub-domain version needs to be added that can work without an authorised user.
Basically a form of multi-site that can map to a TenantParticipant resulting in something approximating what the site inheritance / resolution of ScorpioFramework achieves.
Likely need to either extend TenantParticipant to include "domain" or add a set of domain interfaces then a new Tenant validator that runs before auth and pretty much all other middlewares to create the tenant instance from the current domain. UrlGenerator will need the base URI updating to use the TenantParticipants URI otherwise URIs will be generated for the main application URL.
Might be possible to use this in conjunction with the AuthenticateTenant, though that would be largely redundant as the tenant is already resolved so the Users at this point should be tenant aware (another interface).
Pushed an experimental (buggy) implementation up to master for testing. Had to override the Laravel Foundation/Application class to override the cache file names, and that caused an issue because the auth.tenant service was not registered early enough, so that is now done after parent::__construct(). View folder hierarchies are modified and the initial testing looks promising.
Main concern is about production caching and the paths / routes getting cached globally not by tenant. The cache command may have to be overridden to use the tenant data. This is only an issue in multi-site; the single app multi-tenancy seems to be working pretty well.
Local testing has resulted in the 0.3 branch that supports multi-domain tenancy along with multi-account, multi-domain tenancy.