hubeiwei / yii2-hawk-auth
Hawk authorization for yii2
Package info
github.com/hubeiwei/yii2-hawk-auth
Type:yii2-extension
pkg:composer/hubeiwei/yii2-hawk-auth
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: 2026-02-12 07:14:23 UTC
README
Hawk authorization for yii2, use package: shawm11/hawk-auth-php
Installation
run:
composer require hubeiwei/yii2-hawk-auth 1.0.x-dev
or add:
"hubeiwei/yii2-hawk-auth": "1.0.x-dev"
to the require section of your composer.json file.
Agreement:
id: AppKey
key: AppSecret
algorithm: sha256
Usage
Server
User:
Add AppKey and AppSecret column into your user table
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(); } // ... }
Controller behaviors:
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; }