ancoka / larav-oauth2-client
This is an simple OAuth client service.
Installs: 70
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 0
pkg:composer/ancoka/larav-oauth2-client
Requires
- php: >=5.6
- guzzlehttp/guzzle: 6.*
This package is auto-updated.
Last update: 2025-10-21 07:51:01 UTC
README
larav oauth2 client 是一个针对 Laravel framework 实现的一个简单的 进行 OAuth 认证的扩展包。
安装
-
环境要求
PHP >= 5.6并且laravel >= 5.4 -
安装 larav oauth2 client,只需要添加下面内容到你的 composer.json 文件。然后执行
composer update:"ancoka/larav-oauth2-client": "1.0.*"或者直接执行:
composer require "ancoka/larav-oauth2-client:1.0.*" -
打开
config/app.php文件添加下面内容到providers数组:Ancoka\OAuth\OAuthServiceProvider::class, -
同样在
config/app.php文件中添加下面内容到aliases数组:'OAuth' => Ancoka\OAuth\Facades\OAuth::class, -
运行如下命令发布扩展包内配置文件
config/oauth_client.phpphp artisan vendor:publish --provider="Ancoka\OAuth\OAuthServiceProvider"
使用
路由
生成 OAuth 认证路由,执行以下内容:
php artisan make:oauth
会在 routes/web.php 文件中添加 OAuth::routes() 。
中间件
你可以使用中间件拦截需要进行身份验证的所有路由,类似以下内容:
Route::middleware(['oauth.authorize'])->group(function () {
Route::get('/', 'IndexController@index')->name('home');
});
License
MIT