定制 wjbecker/filament-connectify 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wjbecker/filament-connectify

最新稳定版本:0.0.1

Composer 安装命令:

composer require wjbecker/filament-connectify

包简介

Filament Connectify - Social Login through Laravel Socialite

README 文档

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.

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-04-05