optimus / oauth2-server-lumen
lucadegasperi/oauth2-server-laravel 的 Lumen 桥接器
Requires
This package is auto-updated.
Last update: 2024-09-15 05:04:31 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 以了解用法。