yaroslawww / laravel-fmc-sso-client
FMC SSO client for laravel framework.
1.3.1
2022-10-18 13:22 UTC
Requires
- php: ^8.0
- illuminate/support: ^8.0|^9.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.1
- guzzlehttp/guzzle: ^7.3
- orchestra/testbench: ^6.21
- phpunit/phpunit: ^9.5
- vimeo/psalm: ^4.10
README
If your application uses multiple oAuth providers, it's easier to use a service-independent package like laravel/socialite
Installation
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"
Usage
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