Skip to content

Commit

Permalink
v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
filsh committed Jun 19, 2015
1 parent 9d69443 commit e05fff9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
2 changes: 2 additions & 0 deletions Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace filsh\yii2\oauth2server;

use yii\web\GroupUrlRule;

class Bootstrap implements \yii\base\BootstrapInterface
{
/**
Expand Down
28 changes: 14 additions & 14 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,20 @@
* ```php
* 'oauth2' => [
* 'class' => 'filsh\yii2\oauth2server\Module',
* 'options' => [
* 'token_param_name' => 'accessToken',
* 'access_lifetime' => 3600
* ],
* 'tokenParamName' => 'accessToken',
* 'tokenAccessLifetime' => 3600 * 24,
* 'storageMap' => [
* 'user_credentials' => 'common\models\User'
* 'user_credentials' => 'common\models\User',
* ],
* 'grantTypes' => [
* 'client_credentials' => [
* 'class' => '\OAuth2\GrantType\ClientCredentials',
* 'allow_public_clients' => false
* ],
* 'user_credentials' => [
* 'class' => '\OAuth2\GrantType\UserCredentials'
* 'class' => 'OAuth2\GrantType\UserCredentials',
* ],
* 'refresh_token' => [
* 'class' => '\OAuth2\GrantType\RefreshToken',
* 'class' => 'OAuth2\GrantType\RefreshToken',
* 'always_issue_new_refresh_token' => true
* ]
* ],
* ]
* ]
* ```
*/
Expand All @@ -49,12 +43,18 @@ class Module extends \yii\base\Module
public $storageMap = [];

/**
* @var array GrantTypes map
* @var array GrantTypes collection
*/
public $grantTypes = [];

/**
* @var string name of access token parameter
*/
public $tokenParamName;

/**
* @var type max access lifetime
*/
public $tokenAccessLifetime;

/**
Expand Down Expand Up @@ -95,7 +95,7 @@ public function getServer()
$instance = $reflection->newInstanceArgs($config);
$grantTypes[$name] = $instance;
}

$server = \Yii::$container->get(Server::className(), [
$this,
$storages,
Expand Down
6 changes: 6 additions & 0 deletions Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ public function __construct(Module $module, $storage = array(), array $config =
parent::__construct($storage, $config, $grantTypes, $responseTypes, $tokenType, $scopeUtil, $clientAssertionType);
}

public function createAccessToken($clientId, $userId, $scope = null, $includeRefreshToken = true)
{
$accessToken = $this->getAccessTokenResponseType();
return $accessToken->createAccessToken($clientId, $userId, $scope, $includeRefreshToken);
}

public function verifyResourceRequest(\OAuth2\RequestInterface $request = null, \OAuth2\ResponseInterface $response = null, $scope = null)
{
if($request === null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use yii\helpers\ArrayHelper;
use filsh\yii2\oauth2server\filters\ErrorToExceptionFilter;

class DefaultController extends \yii\rest\Controller
class RestController extends \yii\rest\Controller
{
/**
* @inheritdoc
Expand Down

0 comments on commit e05fff9

Please sign in to comment.