hubeiwei / yii2-hawk-auth
yii2 的 Hawk 授权
1.0.x-dev
2019-03-11 10:33 UTC
Requires
- shawm11/hawk-auth: ^1.0
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2024-09-12 04:12:42 UTC
README
yii2 的 Hawk 授权,使用包: shawm11/hawk-auth-php
安装
运行
composer require hubeiwei/yii2-hawk-auth 1.0.x-dev
或添加
"hubeiwei/yii2-hawk-auth": "1.0.x-dev"
到您的 composer.json 文件的 require 部分。
协议
id: AppKey
key: AppSecret
algorithm: sha256
用法
服务器
用户
将 AppKey 和 AppSecret 列添加到您的用户表中
use hubeiwei\yii2Hawk\Auth as HawkAuth; public static function findIdentityByAccessToken($token, $type = null) { // ... if ($type == HawkAuth::class) { return self::find()->where(['app_key' => $token])->one(); } // ... }
控制器行为
use hubeiwei\yii2Hawk\Auth as HawkAuth; public function behaviors() { $behaviors = parent::behaviors(); $behaviors['authenticator'] = [ 'class' => HawkAuth::class, // 'header' => 'Authorization', // 'algorithm' => 'sha256', // 'keyAttribute' => 'app_secret', ]; return $behaviors; }