wolfpack-it/yii2-oauth
Composer 安装命令:
composer require wolfpack-it/yii2-oauth
包简介
Yii2 OAuth2 server implementation of https://oauth2.thephpleague.com/
README 文档
README
This extension provides The PHP League: OAuth 2.0 Server module for the Yii2 Framework.
The PHP League: OAuth 2.0 Server is a package that makes setting up a OAuth2 server easy.
Installation
The preferred way to install this extension is through composer.
Either run
$ composer require wolfpack-it/yii2-oauth
or add
"wolfpack-it/yii2-oauth": "^<latest version>"
to the require section of your composer.json file.
Configuring
Configure module
The basic configuration is a module in your application:
'modules' => [ 'oauth' => [ 'class' => \WolfpackIT\oauth\Module::class, 'userClass' => '<class of ActiveRecordUser implementing UserEntityInterface>', 'db' => 'db', // component that should be used for the database connection 'publicKey' => '<path to public key file te be used by CryptKey, or configuration>', 'privateKey' => '<path to private key file te be used by CryptKey, or configuration>', 'encryptionKey' => '<random string for encryption>', 'tokenValidationLeeway' => null|int, // The number of seconds to use as leeway when validating access tokens ] ]
See the public variables of the Module for the full configuration options.
An example on how to generate keys can be found here.
Whenever the AccessTokenService is being injected via DI, the module needs to be added to the bootstrap of the application.
Running migrations
The migrations can be ran automatically by adding them to the migration namespaces:
'migrationNamespaces' => [ 'WolfpackIT\oauth\migrations', 'console\migrations', ]
To get this working, you will need to add an alias:
'aliases' => [ '@WolfpackIT/oauth' => '@vendor/wolfpack-it/yii2-oauth/src', ]
If you want to override the database connection in the migrations, you will need to bootstrap the oauth module also in the console.
Add routes
To have the module accessible, make sure the correct routes are set in your urlManager.
For example when your module is called oauth:
'urlManager' => [ 'rules' => [ 'oauth/<controller:[\w-]+>/<action:[\w-]+>' => 'oauth/<controller>/<action>' ] ]
TODO
- Add tests
Credits
License
The MIT License (MIT). Please see LICENSE for more information.
wolfpack-it/yii2-oauth 适用场景与选型建议
wolfpack-it/yii2-oauth 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 960 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 06 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 wolfpack-it/yii2-oauth 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wolfpack-it/yii2-oauth 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 960
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-06-11