-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add readme and license file. renamed isallowedcallback
- Loading branch information
Showing
4 changed files
with
172 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) chrisreedio <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
# Filament Connectify - Social Login through Laravel Socialite | ||
|
||
### Add OAuth2 Login support to Filament v3 through Laravel Socialite | ||
|
||
This package extends [Laravel Socialite](https://laravel.com/docs/master/socialite). Socialite currently supports | ||
authentication via Facebook, Twitter, LinkedIn, Google, GitHub, GitLab, and Bitbucket out of the box. | ||
|
||
Refer to the [Socialite documentation](https://laravel.com/docs/master/socialite) for more information on how to | ||
configure your application to use these providers. | ||
|
||
Many other providers are available via the [Socialite Providers](https://socialiteproviders.com/) website. Refer to the | ||
documentation for each provider for information on how to configure your application to use them. | ||
|
||
--- | ||
|
||
## Installation | ||
|
||
Install package via composer: | ||
```bash | ||
composer require wjbecker/filament-connectify | ||
``` | ||
|
||
Publish & migrate migration files | ||
```bash | ||
php artisan vendor:publish --tag="filament-connectify-migrations | ||
php artisan migrate | ||
``` | ||
To use provider icons you can add [Blade Font Awesome](https://github.com/owenvoke/blade-fontawesome) brand icons | ||
```bash | ||
composer require owenvoke/blade-fontawesome | ||
``` | ||
--- | ||
## Provider Configuration | ||
Refer to the [Socialite documentation](https://laravel.com/docs/master/socialite) for more information. | ||
--- | ||
## Panel Configuration | ||
Include this plugin in your panel configuration: | ||
```php | ||
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](https://socialiteproviders.com/Microsoft-Azure/). | ||
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 | ||
```bash | ||
composer require socialiteproviders/microsoft-azure | ||
``` | ||
Then you would configure your `config/services.php` file to include the Azure provider's credentials: | ||
```php | ||
'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: | ||
```php | ||
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: | ||
```dotenv | ||
AZURE_CLIENT_ID= | ||
AZURE_CLIENT_SECRET= | ||
AZURE_REDIRECT_URI= | ||
AZURE_TENANT_ID= | ||
``` | ||
## Changelog | ||
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. | ||
## Contributing | ||
Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details. | ||
## Security Vulnerabilities | ||
Please review [our security policy](../../security/policy) on how to report security vulnerabilities. | ||
## Credits | ||
- [All Contributors](../../contributors) | ||
## License | ||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters