-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Установка #1
Comments
Нет, этот модуль можно поставить для любого yii2 приложения.
yii migrate --migrationPath=<путь к модулю>/migrations/m140501_075311_add_oauth2_server.php
'modules.oauth2' => [
'class' => 'filsh\yii2\oauth2server\Module',
'options' => [
'token_param_name' => \rest\base\HTTP::PARAM_ACCESS_TOKEN,
'access_lifetime' => 3600 * 24
],
'storageMap' => [
'user_credentials' => 'common\p2s1\models\User'
]
] common\p2s1\models\User - обычная модель реализующая интерфейс OAuth2\Storage\UserCredentialsInterface, таким образом данные о пользователе хранятся в нашей табличке use yii\helpers\ArrayHelper;
use yii\filters\auth\HttpBearerAuth;
use yii\filters\auth\QueryParamAuth;
use filsh\yii2\oauth2server\filters\ErrorToExceptionFilter;
use filsh\yii2\oauth2server\filters\auth\CompositeAuth;
class Controller extends \yii\rest\Controller
{
/**
* @inheritdoc
*/
public function behaviors()
{
return ArrayHelper::merge(parent::behaviors(), [
'authenticator' => [
'class' => CompositeAuth::className(),
'authMethods' => [
['class' => HttpBearerAuth::className()],
['class' => QueryParamAuth::className(), 'tokenParam' => \rest\base\HTTP::PARAM_ACCESS_TOKEN],
]
],
'exceptionFilter' => [
'class' => ErrorToExceptionFilter::className()
],
]);
}
} Этот модуль делался для себя, может для ваших целей он не подойдет. Что бы лучше понять как вообще оно работает нужно разбираться тут https://github.com/bshaffer/oauth2-server-php |
Спасибо. |
ErrorToExceptionFilter crashes because of lack of getErrorMessage method
Здравствуйте. Подскажите, пожалуйста, как правильно установить модуль? Этот модуль только для "yii2-app-advanced" приложений?
The text was updated successfully, but these errors were encountered: