I just need some suggestion regarding single sign on for multiple laravel app. It's connected with same database and same users table. The concept is like ERP system where it has a multiple selection button which linked to the different app and the steps as below:
1) Login/Register (APP1)
2) Redirect to ERP Home(APP1)
3) Select another app and redirect to app2(APP2)
4) Auto login based on APP1 authentication(APP2)
So the APP1 will be the main while the other app authentication dependent to APP1. Any suggestion? So far i have go through the laravel passport and jwt api documentation and its quite different from my goals.
Can i pass the session through the button HREF ? :(
Thanks!
Finally i can able to pass the user id through url and grab them from the route :) Here's the final code in case anyone having a same problem :)
Domain 1
Link the url through button
<a href="http://domain1.com/autologin?id={{ auth::id() }}&api_token=token">Pass uid</a>
Domain 2
Make sure the autologin route are inside web middleware.
web.php
Route::group(['middleware' => ['web']], function () {
Route::get('autologin', function () {
$user = $_GET['id'];
Auth::loginUsingId($user, true);
return redirect()->intended('/dashboard');
});
});
Good luck and thanks ;)
I am just sharing my thoughts.
Process:
Make a token system for communicating within two app.
Token will carry a user id or any kind of unique identity.
If APP1 generated temporary token get matched for APP2 then decode the token and get user unique identity.
You can login any user manually.
Auth::login($user);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With