numesia/laravel-franceconnect-proxy
Composer 安装命令:
composer require numesia/laravel-franceconnect-proxy
包简介
France connect OAuth2 Provider for Laravel Socialite
README 文档
README
France connect OAuth2 Provider for Laravel Socialite (proxy version).
INSTALLATION
1. COMPOSER
// This assumes that you have composer installed globally
composer require numesia/laravel-franceconnect-proxy
2. SERVICE PROVIDER
- Remove
Laravel\Socialite\SocialiteServiceProviderfrom yourproviders[]array inconfig\app.phpif you have added it already. - Add
SocialiteProviders\Manager\ServiceProvider::classto yourproviders[]array inconfig\app.php.
For example:
'providers' => [
// a whole bunch of providers
// remove 'Laravel\Socialite\SocialiteServiceProvider',
SocialiteProviders\Manager\ServiceProvider::class, // add
];
Note: If you would like to use the Socialite Facade, you need to install it.
3. ADD THE EVENT AND LISTENERS
-
Add SocialiteProviders\Manager\SocialiteWasCalled event to your
listen[]array in<app_name>/Providers/EventServiceProvider. -
Add your listeners (i.e. the ones from the providers) to the
SocialiteProviders\Manager\SocialiteWasCalled[]that you just created. -
The listener that you add for this provider is
'SocialiteProviders\LaravelFranceConnect\FranceConnectExtendSocialite@handle',.
Note: You do not need to add anything for the built-in socialite providers unless you override them with your own providers.
For example:
/**
* The event handler mappings for the application.
*
* @var array
*/
protected $listen = [
\SocialiteProviders\Manager\SocialiteWasCalled::class => [
'Numesia\LaravelFranceConnect\FranceConnectExtendSocialite@handle',
],
];
4. ENVIRONMENT VARIABLES
Append provider values to your .env file
// other values above
FRANCECONNECT_SANDBOX=true
FRANCECONNECT_KEY=yourkeyfortheservice
FRANCECONNECT_SECRET=yoursecretfortheservice
FRANCECONNECT_REDIRECT_URI=https://example.com/login/franceconnect/callback
FRANCECONNECT_TOKEN_MODEL=App\Models\Fctoken
USAGE
you are ready to authenticate users! You will need two routes: one for redirecting the user to the OAuth provider, and another for receiving the callback from the provider after authentication.
Route::get('login/franceconnect', 'Auth\LoginController@redirectToProvider');
Route::get('login/franceconnect/callback', 'Auth\LoginController@handleProviderCallback');
We will access Socialite using the Socialite facade (must install socialite):
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Socialite;
class LoginController extends Controller
{
/**
* Redirect the user to the FranceConnect authentication page.
*
* @return Response
*/
public function redirectToProvider()
{
return Socialite::driver('franceconnect')
->scopes(["identite_pivot", "address", "email", "phone", "adresse_postale"])
->redirect();
}
/**
* Obtain the user information from FranceConnect.
*
* @return Response
*/
public function handleProviderCallback()
{
$user = Socialite::driver('franceconnect')->user();
// Do something with $user
}
}
numesia/laravel-franceconnect-proxy 适用场景与选型建议
numesia/laravel-franceconnect-proxy 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 822 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 10 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 numesia/laravel-franceconnect-proxy 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 numesia/laravel-franceconnect-proxy 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 822
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-10-03