Downloads
Stars
Version
If your application uses multiple oAuth providers, it's easier to use a service-independent package like laravel/socialite
Install the package via composer:
composer require yaroslawww/laravel-fmc-sso-client
Set environment variables
# .env
FMC_SSO_CLIENT_ID="123456"
FMC_SSO_CLIENT_SECRET="RvYvYTDtMDt..."
FMC_SSO_REDIRECT_URL="https://my.app.home/fmc-sso/callback"
Optionally you can publish the config file with:
php artisan vendor:publish --provider="FMCSSOClient\ServiceProvider" --tag="config"
The fastest way to add functionality is to create a class that extends SSORouter
use FMCSSOClient\Http\Controllers\SSORouter;
use FMCSSOClient\SSOUser;
class FMCSSORouter extends SSORouter
{
protected function successUserCallback(SSOUser $user): mixed
{
$user->getId();
$user->getName();
$user->getEmail();
// add/update database user based on returned object.
}
// Optional you can add custom scopes
// public function scopes(): array
// {
// return ['my:custom-scope', 'my:other-scope'];
// }
}
Then add routes:
// /routes/web.php
Route::middleware( [ 'guest', /*...*/ ] )->group( fn() => \App\Domain\FMCSSO\FMCSSORouter::routes() );
This is it. The default login route is http://my.domain.home/fmc-sso