mobieve/auth-client
Composer 安装命令:
composer require mobieve/auth-client
包简介
This package provides Classes for Auth Clients made by Mobieve.
README 文档
README
Mobieve Auth Client PHP
This package provides Classes for Auth Clients made by Mobieve.
- Mobieve\AuthClient\Facades\CustomClient
- Mobieve\AuthClient\Middleware\MobieveAuthMiddleware
- Mobieve\AuthClient\Models\CustomClient
- Mobieve\AuthClient\Providers\CustomClientServiceProvider
Mobieve Custom HTTP Client
Configuration
In config/app.php include:
'providers' => [ ... Mobieve\AuthClient\Providers\CustomClientServiceProvider::class ],
and:
'aliases' => [ ... 'JWTFactory' => Tymon\JWTAuth\Facades\JWTFactory::class, 'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class, 'MobieveClient' => Mobieve\AuthClient\Facades\CustomClient::class ],
If user requests is needed you also need to include:
'aliases' => [ ... 'Auth' => Illuminate\Support\Facades\Auth::class, 'User' => App\User::class, 'Team' => App\Team::class ],
You also need to configure auth service info in config/services.php, like:
return [ ... 'auth' => [ 'url' => env('MOBIEVE_AUTH_URL') . '/oauth/token', 'client_id' => env('MOBIEVE_AUTH_CLIENT_ID'), 'client_secret' => env('MOBIEVE_AUTH_CLIENT_SECRET') ] ];
and include your personal MOBIEVE_AUTH_CLIENT_ID and MOBIEVE_AUTH_CLIENT_SECRET in your environment variables.
Usage
MobieveClient::get(string $url, array $params); MobieveClient::post(string $url, array $params); MobieveClient::put(string $url, array $params); MobieveClient::delete(string $url);
Middleware
Four different middleware classes are available.
MobieveClientAuthMiddleware is used to ensure that the requester is a Client registered in Mobieve Auth server.
MobieveUserAuthMiddleware, on the other hand, is used to ensure that the requester is an User registered in Mobieve Auth server.
MobieveUserTeamAuthMiddleware, is used to ensure thar the request is an User with Team registered in Mobieve Auth server.
MobieveAuthMiddleware, will only check if token is valid.
To use Mobieve Middleware layer in order to check incoming requests authorization include following line in Http/Kernel.php:
You need to include the middleware that you want to use in Http/Kernel.php file, as demonstrated below:
protected $routeMiddleware = [ ... 'mobieve.auth-client' => \Mobieve\AuthClient\Middleware\MovieveClientAuthMiddleware::class, 'mobieve.auth-user' => \Mobieve\AuthClient\Middleware\MovieveClientAuthMiddleware::class ];
and add 'mobieve.auth-client' or 'mobieve.auth-user' in all routes you need to protect, according to the desired behavior.
mobieve/auth-client 适用场景与选型建议
mobieve/auth-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 653 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 01 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 mobieve/auth-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mobieve/auth-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 653
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-01-09