-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
136 changed files
with
8,479 additions
and
5,732 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
/vendor | ||
/composer.lock | ||
/tests/coverage | ||
/build | ||
/docs | ||
/testing | ||
build/coverage | ||
/examples/relational/vendor | ||
/examples/relational/config/oauth2.sqlite3 | ||
/examples/nosql/vendor | ||
/examples/nosql/config/oauth2.sqlite3 | ||
/examples/relational/composer.lock | ||
/tests/codecept/tests/_log | ||
oauth2-server.paw | ||
/output_*/ | ||
/_site |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
filter: | ||
excluded_paths: | ||
- tests/* | ||
- vendor/* | ||
- examples/* | ||
checks: | ||
php: | ||
code_rating: true | ||
remove_extra_empty_lines: true | ||
remove_php_closing_tag: true | ||
remove_trailing_whitespace: true | ||
fix_use_statements: | ||
remove_unused: true | ||
preserve_multiple: false | ||
preserve_blanklines: true | ||
order_alphabetically: true | ||
fix_php_opening_tag: true | ||
fix_linefeed: true | ||
fix_line_ending: true | ||
fix_identation_4spaces: true | ||
fix_doc_comments: true | ||
tools: | ||
external_code_coverage: | ||
timeout: 600 | ||
runs: 3 | ||
php_code_coverage: false | ||
php_code_sniffer: | ||
config: | ||
standard: PSR2 | ||
filter: | ||
paths: ['src'] | ||
php_loc: | ||
enabled: true | ||
excluded_dirs: [vendor, tests, examples] | ||
php_cpd: | ||
enabled: true | ||
excluded_dirs: [vendor, tests, examples] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace RelationalExample\Model; | ||
|
||
use Illuminate\Database\Capsule\Manager as Capsule; | ||
|
||
class Users | ||
{ | ||
public function get($username = null) | ||
{ | ||
$query = Capsule::table('users')->select(['username', 'password', 'name', 'email', 'photo']); | ||
|
||
if ($username !== null) { | ||
$query->where('username', '=', $username); | ||
} | ||
|
||
$result = $query->get(); | ||
|
||
if (count($result) > 0) { | ||
return $result; | ||
} | ||
|
||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
|
||
namespace RelationalExample\Storage; | ||
|
||
use League\OAuth2\Server\Storage\AccessTokenInterface; | ||
use League\OAuth2\Server\Storage\Adapter; | ||
use League\OAuth2\Server\Entity\AccessTokenEntity; | ||
use League\OAuth2\Server\Entity\AbstractTokenEntity; | ||
use League\OAuth2\Server\Entity\RefreshTokenEntity; | ||
use League\OAuth2\Server\Entity\ScopeEntity; | ||
|
||
use Illuminate\Database\Capsule\Manager as Capsule; | ||
|
||
class AccessTokenStorage extends Adapter implements AccessTokenInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function get($token) | ||
{ | ||
$result = Capsule::table('oauth_access_tokens') | ||
->where('access_token', $token) | ||
->get(); | ||
|
||
if (count($result) === 1) { | ||
$token = (new AccessTokenEntity($this->server)) | ||
->setId($result[0]['access_token']) | ||
->setExpireTime($result[0]['expire_time']); | ||
|
||
return $token; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getScopes(AbstractTokenEntity $token) | ||
{ | ||
$result = Capsule::table('oauth_access_token_scopes') | ||
->select(['oauth_scopes.id', 'oauth_scopes.description']) | ||
->join('oauth_scopes', 'oauth_access_token_scopes.scope', '=', 'oauth_scopes.id') | ||
->where('access_token', $token->getId()) | ||
->get(); | ||
|
||
$response = []; | ||
|
||
if (count($result) > 0) { | ||
foreach ($result as $row) { | ||
$scope = (new ScopeEntity($this->server))->hydrate([ | ||
'id' => $row['id'], | ||
'description' => $row['description'] | ||
]); | ||
$response[] = $scope; | ||
} | ||
} | ||
|
||
return $response; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function create($token, $expireTime, $sessionId) | ||
{ | ||
Capsule::table('oauth_access_tokens') | ||
->insert([ | ||
'access_token' => $token, | ||
'session_id' => $sessionId, | ||
'expire_time' => $expireTime | ||
]); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function associateScope(AbstractTokenEntity $token, ScopeEntity $scope) | ||
{ | ||
Capsule::table('oauth_access_token_scopes') | ||
->insert([ | ||
'access_token' => $token->getId(), | ||
'scope' => $scope->getId() | ||
]); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function delete(AbstractTokenEntity $token) | ||
{ | ||
Capsule::table('oauth_access_token_scopes') | ||
->where('access_token', $token->getId()) | ||
->delete(); | ||
} | ||
} |
Oops, something went wrong.