1 Star 0 Fork 0

ikaijian / oauth2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

oauth2

开放平台授权组件包,oauth2,oauth2-server.

安装

composer require ikaijian/oauth2 -vvv

使用

发布配置

  • JWT配置文件
  • Redis缓存配置

运行

php artisan vendor:publish --provider="Ikaijian\Oauth2\Oauth2ServiceProvider"

项目中间件配置流程

  • 1.在HttpKernel.php中绑定 \Ikaijian\Oauth2\Middleware\AccessTokenAuthenticate::class 中间件
/**
     * The application's route middleware.
     *
     * These middleware may be assigned to groups or used individually.
     *
     * @var array
     */
    protected $routeMiddleware = [
        // 开放平台授权中间件
        'app.token' => \Ikaijian\Oauth2\Middleware\AccessTokenAuthenticate::class,
    ];
  • 2.在路由指定授权认证中间件
// 开放接口
 \Illuminate\Routing\Route::middleware('app.token')->group(function () {
             
 });       

组件包使用

Token 生成

\Ikaijian\Oauth2\Facades\JwtAuthFacade::token('用户标识', ['params1' => 1, 'params2' => 2])->toString();

Token 验证


try {
    $jwt=\Ikaijian\Oauth2\Facades\JwtAuthFacade::verify($accessToken);
} catch (\Exception $e) {
    throw new \Ikaijian\Oauth2\Exceptions\ApiAuthException(\Ikaijian\Oauth2\Constants\ErrorCode::NOT_TOKEN_VALID_ERROR);
}

Token 刷新

$jwt =\Ikaijian\Oauth2\Facades\JwtAuthFacade::refresh();

Contributing

You can contribute in one of three ways:

  1. File bug reports using the issue tracker.
  2. Answer questions or fix bugs on the issue tracker.
  3. Contribute new features or update the wiki.

The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.

License

MIT

<h1 align="center"> oauth2 </h1> <p align="center"> 开放平台授权组件包,oauth2,oauth2-server.</p> ## 安装 ```shell composer require ikaijian/oauth2 -vvv ``` ## 使用 ### 发布配置 + JWT配置文件 + Redis缓存配置 运行 ```shell php artisan vendor:publish --provider="Ikaijian\Oauth2\Oauth2ServiceProvider" ``` ### 项目中间件配置流程 + 1.在HttpKernel.php中绑定 \Ikaijian\Oauth2\Middleware\AccessTokenAuthenticate::class 中间件 ~~~php /** * The application's route middleware. * * These middleware may be assigned to groups or used individually. * * @var array */ protected $routeMiddleware = [ // 开放平台授权中间件 'app.token' => \Ikaijian\Oauth2\Middleware\AccessTokenAuthenticate::class, ]; ~~~ + 2.在路由指定授权认证中间件 ~~~php // 开放接口 \Illuminate\Routing\Route::middleware('app.token')->group(function () { }); ~~~ ### 组件包使用 #### Token 生成 ~~~php \Ikaijian\Oauth2\Facades\JwtAuthFacade::token('用户标识', ['params1' => 1, 'params2' => 2])->toString(); ~~~ #### Token 验证 ~~~php try { $jwt=\Ikaijian\Oauth2\Facades\JwtAuthFacade::verify($accessToken); } catch (\Exception $e) { throw new \Ikaijian\Oauth2\Exceptions\ApiAuthException(\Ikaijian\Oauth2\Constants\ErrorCode::NOT_TOKEN_VALID_ERROR); } ~~~ #### Token 刷新 ~~~php $jwt =\Ikaijian\Oauth2\Facades\JwtAuthFacade::refresh(); ~~~ ## Contributing You can contribute in one of three ways: 1. File bug reports using the [issue tracker](https://github.com/ikaijian/oauth2/issues). 2. Answer questions or fix bugs on the [issue tracker](https://github.com/ikaijian/oauth2/issues). 3. Contribute new features or update the wiki. _The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable._ ## License MIT

简介

oauth2-services,oauth2 展开 收起
PHP
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/ikaijian/oauth2.git
git@gitee.com:ikaijian/oauth2.git
ikaijian
oauth2
oauth2
master

搜索帮助