longthanhtran/yii2-oauth2-resource-server
Composer 安装命令:
composer require longthanhtran/yii2-oauth2-resource-server
包简介
OAuth 2.0 Resource Server
README 文档
README
Introduction.
The package is a wrapper with League's OAuth2 Server package to implement
Resource Server function. This take bearer access_token and validates against
define OAuth2 authz server before accepting the request.
Current support grant to communicate with OAuth2 authz server is
client_credentials
Setup.
Parameters.
- Prepare the pair of
clientIdandclientSecretinside@app/config/params.phpfile. Authorization Server url also has it detail.
... 'resourceServer' => [ 'authzServerUrl' => 'your-oauth-authz-server-url', 'publicKey' => 'your-public-key-path' ], 'clientCredentials' => [ 'clientId' => 'your-client-id', 'clientSecret' => 'your-client-secret', ] ...
OAuthRequester component
- Inside
@app/config/web.php, put component definition forOAuthRequest
... 'oauthRequester' => [ 'class' => 'longthanhtran\oauth2\filters\OAuthRequester' ] ...
Usage
From your (rest) controller, attach the RequestValidator in behaviors
function, e.g
public function behaviors() { $behaviors = parent::behaviors(); $behaviors['authenticator'] = [ 'class' => 'longthanhtran\oauth2\filters\RequestValidator' ]; return $behaviors; }
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-09-19