I have 2 sites on two domains: site.info(legacy) and sub.site.info(on other server, with other code base on Laravel5.5). I need: when you authorized on site.info and visit sub.site.info laravel read your cookie and auto authorize you on site.
What I made:
Created Middleware "StartSession" who extend Illuminate\Session\Middleware\StartSession with method startSession:
public function startSession(Request $request)
{
event(new SiteAuth($session=parent::startSession($request)));
return $session;
}
In Http\Kernel.php replaced original middleware.
Created:
- Provider (SiteAuthServiceProvider) and registered my StartSession
- Event (SiteAuth)
- Listener (SiteAuthListener),
I will write my auth code in SiteAuthListener@handle.
Is it right way?
Thanks.