Comments (2)
Нет, этот модуль можно поставить для любого 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, таким образом данные о пользователе хранятся в нашей табличке
4. В контролере определить поведения, у меня так
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
from yii2-oauth2-server.
Спасибо.
from yii2-oauth2-server.
Related Issues (20)
- Is this project still live? HOT 3
- yii 2.0.13 has erros!~ HOT 7
- Authorization url
- 不能使用授权码认证(AuthorizationCode) HOT 1
- oauth2/token 使用最新的yii2版本,访问报错 HOT 1
- Module.php getRequest() function has an error after yii 2.0.13 HOT 5
- How to install and run HOT 6
- where is a example? HOT 1
- Add 'auth_code_lifetime' support to config HOT 1
- Declaration of m140501_075311_add_oauth2_server::primaryKey($columns) should be compatible with yii\db\Migration::primaryKey($length = NULL) HOT 2
- document error for migration HOT 1
- Calling unknown method: filsh\yii2\oauth2server\Module::handleAuthorizeRequest() HOT 2
- How to use scopes?
- How to add own field in login responce? HOT 1
- Not able to generate token getting handleAuthorizeRequest error HOT 4
- Invalid credentials
- Need more example with Yii2 Auth client integration
- How to use this extension with official Yii2 AuthClient ? HOT 1
- How to implement OpenID Connect ?
- ASK, how to get the public key to show to specific url HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yii2-oauth2-server.