This is a basic module for app registration. It registers applications through the background and verifies the API in the way of basic authentication (这是一个app注册的基本模块,通过后台注册应用,以基本认证的方式对api进行验证)
'controllerMap' => [
'migrate' => [
'class' => 'yii\console\controllers\MigrateController',
'migrationPath' => [
'@graychen/yii2/basic/auth/migrations'
],
],
],
$ yii migrate/up
'auth' => [
'class' => 'graychen\yii2\basic\auth\Module',
]
after that,you can website https://localhost/admin/app
use graychen\yii2\basic\auth\models\App;
use graychen\yii2\basic\auth\filters\HttpBasicAuth;
public function behaviors()
{
return [
'authenticator' => [
'class' => HttpBasicAuth::className(),
'auth' => function ($username, $password) {
return App::findOne([
'app_key' => $username,
'app_secret' => $password,
]);
}
]
];
}