Skip to content
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

update master #2

Merged
merged 65 commits into from
Jun 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
e5084e3
Update Server.php
pelegrin Jul 3, 2015
6466920
Merge pull request #33 from pelegrin/v2.0.1
filsh Jul 5, 2015
3a32949
Updated Module params phpDocs
freezy-sk Jul 6, 2015
b005ade
Added option to set custom ResponseTypes
freezy-sk Jul 6, 2015
f7107d5
Merge pull request #34 from freezy-sk/feature/response-types-option
filsh Jul 6, 2015
e2bf955
adding support when OAuth2 is nested to another module
rzani Jul 13, 2015
009b1af
v2.0.0
filsh Jun 16, 2015
519f154
Update composer.json
filsh Jun 17, 2015
baf3ac9
Oauth module v2.0
filsh Jun 18, 2015
2a80d8b
Oauth module v2.0
filsh Jun 19, 2015
a3d5918
v2.0.0
filsh Jun 19, 2015
b8af7cf
Update Server.php
pelegrin Jul 3, 2015
5ae72fa
Updated Module params phpDocs
freezy-sk Jul 6, 2015
f609415
Added option to set custom ResponseTypes
freezy-sk Jul 6, 2015
276b105
Added support refresh_token_lifetime option
filsh Jul 14, 2015
36dc163
Remove a fixed module ID
filsh Jul 14, 2015
0d8457c
Remove a fixed module ID
filsh Jul 14, 2015
50231c6
Remove a fixed module ID
filsh Jul 14, 2015
a7c95fd
Update README.md
filsh Jul 14, 2015
4a98bc0
Created helpers for Authorization Code and update README.md
Sep 20, 2015
bb8e2b0
Merge pull request #53 from femike/v2.0.1
filsh Sep 22, 2015
dfd3496
Update codestyle
filsh Sep 22, 2015
1b7aebc
Enforce State and Implicit Grant Type
tuxoff Oct 26, 2015
71866ae
Update README.md
tuxoff Oct 26, 2015
8fcbac0
Merge pull request #58 from dmtux/v2.0.1
filsh Oct 26, 2015
d8c3aba
Add Support for JWT Tokens
mtangoo Jan 5, 2016
d8c9213
Explaining how to use JWT
mtangoo Jan 5, 2016
ba0de54
Merge pull request #69 from hosannahighertech/v2.0.1
filsh Jan 6, 2016
d4c6cf4
Fix documentation to simplify things in JWT things
mtangoo Feb 7, 2016
5088fed
Merge pull request #74 from mtangoo/patch-1
filsh Feb 8, 2016
0cb8034
added `Module::$options` in a compatible fashion
hiqsol Feb 17, 2016
60a555b
add revoke request action
lisps Apr 7, 2016
6af4983
add revoke request to Server.php
lisps Apr 7, 2016
d8e94a6
Merge pull request #83 from lisps/patch-2
filsh Apr 8, 2016
d4938c2
Manual merge of https://github.com/Filsh/yii2-oauth2-server/pull/75/f…
Apr 29, 2016
44aa609
Merge pull request #75 from hiqdev/unified_options
filsh Jun 13, 2016
54a1d41
Fix for migration error [Issue 45]
ruslanbes Jul 12, 2016
8861b8c
Merge branch 'v2.0.1' of https://github.com/Filsh/yii2-oauth2-server …
Aug 15, 2016
d7e798d
Added storageName property to grantTypes map.
Aug 23, 2016
5103178
Add the HTTP headers when parsing a OAuth2 response.
Aug 23, 2016
7b1e748
Merge branch 'storagemap-name' into eborned
Aug 23, 2016
ca22a86
Merge branch 'add-headers-to-errors' into eborned
Aug 23, 2016
ba7c7f0
Add OpenID Connect UserInfo end-point to REST controller
jcherniak Nov 8, 2016
ae91739
Merge pull request #112 from pinfirestudios/openid-connect-user-info
filsh Nov 24, 2016
830ffa2
Merge pull request #98 from ruslanbes/patch-1
filsh Dec 21, 2016
91cb3bf
Migration Support for Oracle
ldrc2895 Jan 18, 2018
9e65eef
Conflict resolving
ldrc2895 Jan 18, 2018
a3d4fe8
Fix readme.md
ldrc2895 Jan 18, 2018
24d4b58
Error To Exception Filter fix
ldrc2895 Jan 18, 2018
09cc3a7
Module fix
ldrc2895 Jan 18, 2018
07b8024
Add Support Cors
rizafr Feb 13, 2019
4012187
Fixing the error message problem in the exception file
Synida Mar 27, 2019
fa53207
update readme
Synida Mar 27, 2019
00bf1a6
Merge branch 'v2.0.1'
jcherniak Dec 25, 2019
6a49b99
Merge remote-tracking branch 'optecwizdom/master'
jcherniak Dec 25, 2019
694e31f
Use newer bshaffer package
jcherniak Dec 25, 2019
9bb5400
Rename package and update readme
jcherniak Dec 25, 2019
71335ef
Rename branch alias
jcherniak Dec 25, 2019
0de53af
Add filter that lets you validate a request has a valid 'Client Crede…
jcherniak Dec 25, 2019
a36ffa7
Rewrite ErrorToExceptionFilter to actually be an ActionFilter, not ju…
jcherniak Dec 25, 2019
7b84c3e
Merge remote-tracking branch 'synida/master'
jcherniak Dec 25, 2019
fee225e
Merge remote-tracking branch 'rizafr/support-cors'
jcherniak Dec 25, 2019
714b360
Typo fix from merges in Module::getResponse
jcherniak Dec 25, 2019
8123831
Add Introspect endpoint
jcherniak Dec 25, 2019
cf7ef55
Merge remote-tracking branch 'eborned/eborned'
jcherniak Dec 25, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ nbproject
Thumbs.db
*.sublime-project
*.sublime-workspace

composer.lock
48 changes: 9 additions & 39 deletions Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,15 @@

namespace filsh\yii2\oauth2server;

use yii\web\GroupUrlRule;

/**
* Instead use bootstrap module
* should be removed in v2.1 version
*
* @deprecated v2.0.1
*/
class Bootstrap implements \yii\base\BootstrapInterface
{
/**
* @var array Model's map
*/
private $_modelMap = [
'OauthClients' => 'filsh\yii2\oauth2server\models\OauthClients',
'OauthAccessTokens' => 'filsh\yii2\oauth2server\models\OauthAccessTokens',
'OauthAuthorizationCodes' => 'filsh\yii2\oauth2server\models\OauthAuthorizationCodes',
'OauthRefreshTokens' => 'filsh\yii2\oauth2server\models\OauthRefreshTokens',
'OauthScopes' => 'filsh\yii2\oauth2server\models\OauthScopes',
];

/**
* @var array Storage's map
*/
private $_storageMap = [
'access_token' => 'filsh\yii2\oauth2server\storage\Pdo',
'authorization_code' => 'filsh\yii2\oauth2server\storage\Pdo',
'client_credentials' => 'filsh\yii2\oauth2server\storage\Pdo',
'client' => 'filsh\yii2\oauth2server\storage\Pdo',
'refresh_token' => 'filsh\yii2\oauth2server\storage\Pdo',
'user_credentials' => 'filsh\yii2\oauth2server\storage\Pdo',
'public_key' => 'filsh\yii2\oauth2server\storage\Pdo',
'jwt_bearer' => 'filsh\yii2\oauth2server\storage\Pdo',
'scope' => 'filsh\yii2\oauth2server\storage\Pdo',
];
use BootstrapTrait;

/**
* @inheritdoc
Expand All @@ -39,21 +19,11 @@ public function bootstrap($app)
{
/** @var $module Module */
if ($app->hasModule('oauth2') && ($module = $app->getModule('oauth2')) instanceof Module) {
$this->_modelMap = array_merge($this->_modelMap, $module->modelMap);
foreach ($this->_modelMap as $name => $definition) {
\Yii::$container->set("filsh\\yii2\\oauth2server\\models\\" . $name, $definition);
$module->modelMap[$name] = is_array($definition) ? $definition['class'] : $definition;
}

$this->_storageMap = array_merge($this->_storageMap, $module->storageMap);
foreach ($this->_storageMap as $name => $definition) {
\Yii::$container->set($name, $definition);
$module->storageMap[$name] = is_array($definition) ? $definition['class'] : $definition;
}
$this->initModule($module);

if ($app instanceof \yii\console\Application) {
$module->controllerNamespace = 'filsh\yii2\oauth2server\commands';
}
}
}
}
}
47 changes: 47 additions & 0 deletions BootstrapTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace filsh\yii2\oauth2server;

trait BootstrapTrait
{
/**
* @var array Model's map
*/
private $_modelMap = [
'OauthClients' => 'filsh\yii2\oauth2server\models\OauthClients',
'OauthAccessTokens' => 'filsh\yii2\oauth2server\models\OauthAccessTokens',
'OauthAuthorizationCodes' => 'filsh\yii2\oauth2server\models\OauthAuthorizationCodes',
'OauthRefreshTokens' => 'filsh\yii2\oauth2server\models\OauthRefreshTokens',
'OauthScopes' => 'filsh\yii2\oauth2server\models\OauthScopes',
];

/**
* @var array Storage's map
*/
private $_storageMap = [
'access_token' => 'filsh\yii2\oauth2server\storage\Pdo',
'authorization_code' => 'filsh\yii2\oauth2server\storage\Pdo',
'client_credentials' => 'filsh\yii2\oauth2server\storage\Pdo',
'client' => 'filsh\yii2\oauth2server\storage\Pdo',
'refresh_token' => 'filsh\yii2\oauth2server\storage\Pdo',
'user_credentials' => 'filsh\yii2\oauth2server\storage\Pdo',
'public_key' => 'filsh\yii2\oauth2server\storage\Pdo',
'jwt_bearer' => 'filsh\yii2\oauth2server\storage\Pdo',
'scope' => 'filsh\yii2\oauth2server\storage\Pdo',
];

protected function initModule(Module $module)
{
$this->_modelMap = array_merge($this->_modelMap, $module->modelMap);
foreach ($this->_modelMap as $name => $definition) {
\Yii::$container->set("filsh\\yii2\\oauth2server\\models\\" . $name, $definition);
$module->modelMap[$name] = is_array($definition) ? $definition['class'] : $definition;
}

$this->_storageMap = array_merge($this->_storageMap, $module->storageMap);
foreach ($this->_storageMap as $name => $definition) {
\Yii::$container->set($name, $definition);
$module->storageMap[$name] = is_array($definition) ? $definition['class'] : $definition;
}
}
}
19 changes: 12 additions & 7 deletions Module.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ class Module extends \yii\base\Module
*/
public $grantTypes = [];

/**
* @var array server options
*/
public $options = [];

/**
* @var string name of access token parameter
*/
Expand All @@ -62,7 +67,6 @@ class Module extends \yii\base\Module
* @var bool whether to use JWT tokens
*/
public $useJwtToken = false;//ADDED

/**
* @inheritdoc
*/
Expand All @@ -88,7 +92,7 @@ public function getServer()
if($this->useJwtToken)
{
if(!array_key_exists('access_token', $this->storageMap) || !array_key_exists('public_key', $this->storageMap)) {
throw new \yii\base\InvalidConfigException('access_token and public_key must be set or set useJwtToken to false');
throw new \yii\base\InvalidConfigException('access_token and public_key must be set or set useJwtToken to false');
}
//define dependencies when JWT is used instead of normal token
\Yii::$container->clear('public_key'); //remove old definition
Expand All @@ -105,15 +109,16 @@ public function getServer()

$grantTypes = [];
foreach($this->grantTypes as $name => $options) {
if(!isset($storages[$name]) || empty($options['class'])) {
$storageName = !empty($options['storageName']) ? $options['storageName'] : $name;
if(!isset($storages[$storageName]) || empty($options['class'])) {
throw new \yii\base\InvalidConfigException('Invalid grant types configuration.');
}

$class = $options['class'];
unset($options['class']);

$reflection = new \ReflectionClass($class);
$config = array_merge([0 => $storages[$name]], [$options]);
$config = array_merge([0 => $storages[$storageName]], [$options]);

$instance = $reflection->newInstanceArgs($config);
$grantTypes[$name] = $instance;
Expand All @@ -122,12 +127,12 @@ public function getServer()
$server = \Yii::$container->get(Server::className(), [
$this,
$storages,
[
array_merge(array_filter([
'use_jwt_access_tokens' => $this->useJwtToken,//ADDED
'token_param_name' => $this->tokenParamName,
'access_lifetime' => $this->tokenAccessLifetime,
/** add more ... */
],
]), $this->options),
$grantTypes
]);

Expand All @@ -147,7 +152,7 @@ public function getRequest()

public function getResponse()
{
if(!ArrayHelper::keyExists('request', $this->getComponents())) {
if(!ArrayHelper::keyExists('response', $this->getComponents())) {
$this->set('response', new Response());
}
return $this->get('response');
Expand Down
Loading