tiagodsn / oauth2-server-lumen
lucadegasperi/oauth2-server-laravel 的 Lumen 桥接器
Requires
This package is not auto-updated.
Last update: 2024-09-18 18:48:54 UTC
README
lucadegasperi/oauth2-server-laravel 的 Lumen 桥接器。
指南
我在这里写了一篇关于其使用的详细博客文章。
使用 Lumen 网络API 和 OAuth2 认证构建网络应用程序
安装
通过 composer
运行 composer require optimus/oauth2-server-lumen 0.1.*
注册包
在您的 bootstrap/app.php 中注册服务提供者
$app->register('LucaDegasperi\OAuth2Server\Storage\FluentStorageServiceProvider');
$app->register('Optimus\OAuth2Server\OAuth2ServerServiceProvider');
... 以及中间件
$app->middleware([
'LucaDegasperi\OAuth2Server\Middleware\OAuthExceptionHandlerMiddleware'
]);
... 以及路由中间件
$app->routeMiddleware([
'check-authorization-params' => 'Optimus\OAuth2Server\Middleware\CheckAuthCodeRequestMiddleware',
'csrf' => 'Laravel\Lumen\Http\Middleware\VerifyCsrfToken',
'oauth' => 'Optimus\OAuth2Server\Middleware\OAuthMiddleware',
'oauth-owner' => 'Optimus\OAuth2Server\Middleware\OAuthOwnerMiddleware'
]);
复制配置文件
将 vendor/lucadegasperi/oauth2-server-laravel/config/oauth2.php 复制到您自己的配置文件夹(项目根目录下的 config/oauth2.php)。它必须是在使用 $app->configure() 注册的正确配置文件夹。
迁移
运行 php artisan migrate --path=vendor/lucadegasperi/oauth2-server-laravel/migrations
如果您收到一个错误,说找不到 Config 类,请将 class_alias('Illuminate\Support\Facades\Config', 'Config'); 添加到您的 bootstrap/app.php 文件中,并暂时取消注释 $app->withFacades(); 以导入迁移。
使用方法
该包现在已安装到 Lumen 中。使用方法与 lucadegasperi/oauth2-server-laravel 相同,因此建议您阅读 wiki 了解使用方法。