pechanxur / laravel-firebase-auth
使用Google Firebase Auth保护您的laravel API
dev-master
2020-03-04 02:35 UTC
Requires
- php: >=7.3
- illuminate/contracts: ^7.0.2
- illuminate/support: ^7.0.2
- kreait/firebase-tokens: ^1.10.0
This package is auto-updated.
Last update: 2024-09-04 12:36:54 UTC
README
使用Google Firebase Auth保护您的laravel API
将中间件添加到您的API中,将确保只有使用由Google Firebase Auth签发的有效Bearer Token才能获得访问权限。
安装
composer require pechanxur/laravel-firebase-auth
发布包的配置。
php artisan vendor:publish
这将添加一个firebase.php配置文件,您需要在其中添加您的Firebase 项目ID。
使用方法
有两种使用方法。
1. 无JWT令牌锁定访问
在您的Kernel.php文件中添加中间件。
\pechanxur\LaravelFirebaseAuth\Middleware\JWTAuth::class,
2. 锁定访问并识别客户端请求者
将服务提供者添加到您的config/app.php
pechanxur\LaravelFirebaseAuth\FirebaseAuthServiceProvider::class,
在AuthServiceProvider.php中注册您的新Guard
$this->app['auth']->viaRequest('firebase', function ($request) { return app(\pechanxur\LaravelFirebaseAuth\Guard::class)->user($request); });
现在在auth.php中配置Guard驱动为'firebase'。
'providers' => [ 'users' => [ 'driver' => 'firebase', 'model' => \pechanxur\LaravelFirebaseAuth\User::class, ], ],
待办事项:改进示例
支持
欢迎提出问题和提供反馈。