wjbecker / filament-connectify
Filament Connectify - Social Login through Laravel Socialite
Requires
- php: ^8.0
- laravel/socialite: ^5.12
- owenvoke/blade-fontawesome: *
- spatie/laravel-package-tools: ^1.0|^1.13
This package is auto-updated.
Last update: 2024-05-05 15:37:36 UTC
README
Add OAuth2 Login support to Filament v3 through Laravel Socialite
This package extends Laravel Socialite. Socialite currently supports authentication via Facebook, Twitter, LinkedIn, Google, GitHub, GitLab, and Bitbucket out of the box.
Refer to the Socialite documentation for more information on how to configure your application to use these providers.
Many other providers are available via the Socialite Providers website. Refer to the documentation for each provider for information on how to configure your application to use them.
Installation
Install package via composer:
composer require wjbecker/filament-connectify
Publish & migrate migration files
php artisan vendor:publish --tag="filament-connectify-migrations php artisan migrate
To use provider icons you can add Blade Font Awesome brand icons
composer require owenvoke/blade-fontawesome
Provider Configuration
Refer to the Socialite documentation for more information.
Panel Configuration
Include this plugin in your panel configuration:
use Wjbecker\FilamentConnectify\FilamentConnectifyPlugin; return $panel // ... ->plugins([ // ... Other Plugins FilamentConnectifyPlugin::make() // (required) add providers ->providers([ 'azure' => [ 'label' => 'Continue with Microsoft', 'icon' => 'fab-microsoft', // requires additional package ] ]) // (optional) restrict login callback ->isAllowedCallback(function (\SocialiteProviders\Manager\OAuth2\User $socialiteUser) { $decodedToken = json_decode(base64_decode(str_replace('_', '/', str_replace('-','+',explode('.', $socialiteUser->token)[1])))); return $decodedToken->tid === {{azure_tenant_id}}; }) // (optional) change the user model class ->userModel(\App\Models\User::class) // (optional) change redirect url callback ->redirectUrlCallback(function ($provider) { return 'https://'.tenant('id').'.foo.test'.route(FilamentConnectifyPlugin::get()->getCallbackRoute(), $provider, false); }) ])
Sample Provider Configuration - Azure Active Directory
To start, You would refer to the documentation for the Azure Socialite Provider.
Normally, you would follow the providers documentation on the aforementioned link but to demonstrate, I'll include the steps here.
Per their documentation, you would install the community Azure provider via
composer require socialiteproviders/microsoft-azure
Then you would configure your config/services.php
file to include the Azure provider's credentials:
'azure' => [ 'client_id' => env('AZURE_CLIENT_ID'), 'client_secret' => env('AZURE_CLIENT_SECRET'), 'redirect' => env('AZURE_REDIRECT_URI'), 'tenant' => env('AZURE_TENANT_ID'), 'proxy' => env('PROXY') // optionally ],
In addition, you need to add this provider's event listener to your app/Providers/EventServiceProvider.php
file:
protected $listen = [ // ... other listeners \SocialiteProviders\Manager\SocialiteWasCalled::class => [ // ... other providers \SocialiteProviders\Azure\AzureExtendSocialite::class.'@handle', ], ];
Finally, don't forget to add the needed environment variables to your .env
file:
AZURE_CLIENT_ID= AZURE_CLIENT_SECRET= AZURE_REDIRECT_URI= AZURE_TENANT_ID=
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.