mirror of
https://github.com/elyby/oauth2-server.git
synced 2025-05-31 14:12:07 +05:30
Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
34a6b66b8c | ||
|
61738a7fe2 | ||
|
51184259d1 | ||
|
b21de11429 | ||
|
cf6e86c9d4 | ||
|
f6fdbc7142 | ||
|
7f7f45662a | ||
|
f92a68cc72 | ||
|
295d8ffa24 | ||
|
3d08140651 | ||
|
ec8a8393ee | ||
|
3869b8f406 | ||
|
7da7484008 | ||
|
b42ba4af17 | ||
|
dd795a82f4 | ||
|
166362d3cd | ||
|
d43391564c | ||
|
ea6edf572a |
12
.travis.yml
12
.travis.yml
@@ -1,10 +1,22 @@
|
||||
language: php
|
||||
|
||||
sudo: false
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- vendor
|
||||
|
||||
php:
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- hhvm
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php: 7.0
|
||||
fast_finish: true
|
||||
|
||||
install:
|
||||
- travis_retry composer install --no-interaction --prefer-source
|
||||
|
@@ -1,5 +1,9 @@
|
||||
# Changelog
|
||||
|
||||
## 4.1.2 (released 2015-01-01)
|
||||
|
||||
* Remove side-effects in hash_equals() implementation (Issue #290)
|
||||
|
||||
## 4.1.1 (released 2014-12-31)
|
||||
|
||||
* Changed `symfony/http-foundation` dependency version to `~2.4` so package can be installed in Laravel `4.1.*`
|
||||
|
@@ -55,6 +55,10 @@ Please see [CONTRIBUTING](https://github.com/thephpleague/oauth2-server/blob/mas
|
||||
|
||||
Bugs and feature request are tracked on [GitHub](https://github.com/thephpleague/oauth2-server/issues)
|
||||
|
||||
## Security
|
||||
|
||||
If you discover any security related issues, please email hello@alexbilbie.com instead of using the issue tracker.
|
||||
|
||||
## License
|
||||
|
||||
This package is released under the MIT License. See the bundled [LICENSE](https://github.com/thephpleague/oauth2-server/blob/master/LICENSE) file for details.
|
||||
|
@@ -6,7 +6,7 @@
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"symfony/http-foundation": "~2.4",
|
||||
"league/event": "1.0.*"
|
||||
"league/event": "~2.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.3.*",
|
||||
|
@@ -86,7 +86,7 @@ class AccessTokenStorage extends AbstractStorage implements AccessTokenInterface
|
||||
*/
|
||||
public function delete(AccessTokenEntity $token)
|
||||
{
|
||||
Capsule::table('oauth_access_token_scopes')
|
||||
Capsule::table('oauth_access_tokens')
|
||||
->where('access_token', $token->getId())
|
||||
->delete();
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@
|
||||
namespace League\OAuth2\Server\Entity;
|
||||
|
||||
/**
|
||||
* Access token entity class
|
||||
* Auth Code entity class
|
||||
*/
|
||||
class AuthCodeEntity extends AbstractTokenEntity
|
||||
{
|
||||
|
@@ -148,7 +148,6 @@ class AuthCodeGrant extends AbstractGrant
|
||||
$session = new SessionEntity($this->server);
|
||||
$session->setOwner($type, $typeId);
|
||||
$session->associateClient($authParams['client']);
|
||||
$session->save();
|
||||
|
||||
// Create a new auth code
|
||||
$authCode = new AuthCodeEntity($this->server);
|
||||
@@ -158,8 +157,10 @@ class AuthCodeGrant extends AbstractGrant
|
||||
|
||||
foreach ($authParams['scopes'] as $scope) {
|
||||
$authCode->associateScope($scope);
|
||||
$session->associateScope($scope);
|
||||
}
|
||||
|
||||
$session->save();
|
||||
$authCode->setSession($session);
|
||||
$authCode->save();
|
||||
|
||||
|
@@ -12,6 +12,8 @@
|
||||
namespace League\OAuth2\Server;
|
||||
|
||||
use League\OAuth2\Server\Entity\AccessTokenEntity;
|
||||
use League\OAuth2\Server\Exception\AccessDeniedException;
|
||||
use League\OAuth2\Server\Exception\InvalidRequestException;
|
||||
use League\OAuth2\Server\Storage\AccessTokenInterface;
|
||||
use League\OAuth2\Server\Storage\ClientInterface;
|
||||
use League\OAuth2\Server\Storage\ScopeInterface;
|
||||
@@ -40,10 +42,10 @@ class ResourceServer extends AbstractServer
|
||||
/**
|
||||
* Initialise the resource server
|
||||
*
|
||||
* @param SessionInterface $sessionStorage
|
||||
* @param AccessTokenInterface $accessTokenStorage
|
||||
* @param ClientInterface $clientStorage
|
||||
* @param ScopeInterface $scopeStorage
|
||||
* @param \League\OAuth2\Server\Storage\SessionInterface $sessionStorage
|
||||
* @param \League\OAuth2\Server\Storage\AccessTokenInterface $accessTokenStorage
|
||||
* @param \League\OAuth2\Server\Storage\ClientInterface $clientStorage
|
||||
* @param \League\OAuth2\Server\Storage\ScopeInterface $scopeStorage
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
@@ -93,31 +95,32 @@ class ResourceServer extends AbstractServer
|
||||
/**
|
||||
* Checks if the access token is valid or not
|
||||
*
|
||||
* @param bool $headersOnly Limit Access Token to Authorization header only
|
||||
* @param AccessTokenEntity|null $accessToken Access Token
|
||||
* @param bool $headerOnly Limit Access Token to Authorization header
|
||||
* @param \League\OAuth2\Server\Entity\AccessTokenEntity|null $accessToken Access Token
|
||||
*
|
||||
* @throws \League\OAuth2\Server\Exception\AccessDeniedException
|
||||
* @throws \League\OAuth2\Server\Exception\InvalidRequestException
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws
|
||||
*/
|
||||
public function isValidRequest($headersOnly = true, $accessToken = null)
|
||||
public function isValidRequest($headerOnly = true, $accessToken = null)
|
||||
{
|
||||
$accessTokenString = ($accessToken !== null)
|
||||
? $accessToken
|
||||
: $this->determineAccessToken($headersOnly);
|
||||
: $this->determineAccessToken($headerOnly);
|
||||
|
||||
// Set the access token
|
||||
$this->accessToken = $this->getAccessTokenStorage()->get($accessTokenString);
|
||||
|
||||
// Ensure the access token exists
|
||||
if (!$this->accessToken instanceof AccessTokenEntity) {
|
||||
throw new Exception\AccessDeniedException();
|
||||
throw new AccessDeniedException();
|
||||
}
|
||||
|
||||
// Check the access token hasn't expired
|
||||
// Ensure the auth code hasn't expired
|
||||
if ($this->accessToken->isExpired() === true) {
|
||||
throw new Exception\AccessDeniedException();
|
||||
throw new AccessDeniedException();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -126,24 +129,24 @@ class ResourceServer extends AbstractServer
|
||||
/**
|
||||
* Reads in the access token from the headers
|
||||
*
|
||||
* @param bool $headersOnly Limit Access Token to Authorization header only
|
||||
* @param bool $headerOnly Limit Access Token to Authorization header
|
||||
*
|
||||
* @throws Exception\InvalidRequestException Thrown if there is no access token presented
|
||||
* @throws \League\OAuth2\Server\Exception\InvalidRequestException Thrown if there is no access token presented
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function determineAccessToken($headersOnly = false)
|
||||
public function determineAccessToken($headerOnly = false)
|
||||
{
|
||||
if ($this->getRequest()->headers->get('Authorization') !== null) {
|
||||
$accessToken = $this->getTokenType()->determineAccessTokenInHeader($this->getRequest());
|
||||
} elseif ($headersOnly === false) {
|
||||
} elseif ($headerOnly === false) {
|
||||
$accessToken = ($this->getRequest()->server->get('REQUEST_METHOD') === 'GET')
|
||||
? $this->getRequest()->query->get($this->tokenKey)
|
||||
: $this->getRequest()->request->get($this->tokenKey);
|
||||
}
|
||||
|
||||
if (empty($accessToken)) {
|
||||
throw new Exception\InvalidRequestException('access token');
|
||||
throw new InvalidRequestException('access token');
|
||||
}
|
||||
|
||||
return $accessToken;
|
||||
|
@@ -24,7 +24,7 @@ interface AccessTokenInterface extends StorageInterface
|
||||
*
|
||||
* @param string $token The access token
|
||||
*
|
||||
* @return \League\OAuth2\Server\Entity\AccessTokenEntity
|
||||
* @return \League\OAuth2\Server\Entity\AccessTokenEntity | null
|
||||
*/
|
||||
public function get($token);
|
||||
|
||||
@@ -33,7 +33,7 @@ interface AccessTokenInterface extends StorageInterface
|
||||
*
|
||||
* @param \League\OAuth2\Server\Entity\AccessTokenEntity $token The access token
|
||||
*
|
||||
* @return array Array of \League\OAuth2\Server\Entity\ScopeEntity
|
||||
* @return \League\OAuth2\Server\Entity\ScopeEntity[] Array of \League\OAuth2\Server\Entity\ScopeEntity
|
||||
*/
|
||||
public function getScopes(AccessTokenEntity $token);
|
||||
|
||||
|
@@ -24,7 +24,7 @@ interface AuthCodeInterface extends StorageInterface
|
||||
*
|
||||
* @param string $code
|
||||
*
|
||||
* @return \League\OAuth2\Server\Entity\AuthCodeEntity
|
||||
* @return \League\OAuth2\Server\Entity\AuthCodeEntity | null
|
||||
*/
|
||||
public function get($code);
|
||||
|
||||
@@ -45,7 +45,7 @@ interface AuthCodeInterface extends StorageInterface
|
||||
*
|
||||
* @param \League\OAuth2\Server\Entity\AuthCodeEntity $token The auth code
|
||||
*
|
||||
* @return array Array of \League\OAuth2\Server\Entity\ScopeEntity
|
||||
* @return \League\OAuth2\Server\Entity\ScopeEntity[] Array of \League\OAuth2\Server\Entity\ScopeEntity
|
||||
*/
|
||||
public function getScopes(AuthCodeEntity $token);
|
||||
|
||||
|
@@ -26,7 +26,7 @@ interface ClientInterface extends StorageInterface
|
||||
* @param string $redirectUri The client's redirect URI (default = "null")
|
||||
* @param string $grantType The grant type used (default = "null")
|
||||
*
|
||||
* @return \League\OAuth2\Server\Entity\ClientEntity
|
||||
* @return \League\OAuth2\Server\Entity\ClientEntity | null
|
||||
*/
|
||||
public function get($clientId, $clientSecret = null, $redirectUri = null, $grantType = null);
|
||||
|
||||
@@ -35,7 +35,7 @@ interface ClientInterface extends StorageInterface
|
||||
*
|
||||
* @param \League\OAuth2\Server\Entity\SessionEntity $session The session
|
||||
*
|
||||
* @return \League\OAuth2\Server\Entity\ClientEntity
|
||||
* @return \League\OAuth2\Server\Entity\ClientEntity | null
|
||||
*/
|
||||
public function getBySession(SessionEntity $session);
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ interface RefreshTokenInterface extends StorageInterface
|
||||
*
|
||||
* @param string $token
|
||||
*
|
||||
* @return \League\OAuth2\Server\Entity\RefreshTokenEntity
|
||||
* @return \League\OAuth2\Server\Entity\RefreshTokenEntity | null
|
||||
*/
|
||||
public function get($token);
|
||||
|
||||
|
@@ -23,7 +23,7 @@ interface ScopeInterface extends StorageInterface
|
||||
* @param string $grantType The grant type used in the request (default = "null")
|
||||
* @param string $clientId The client sending the request (default = "null")
|
||||
*
|
||||
* @return \League\OAuth2\Server\Entity\ScopeEntity
|
||||
* @return \League\OAuth2\Server\Entity\ScopeEntity | null
|
||||
*/
|
||||
public function get($scope, $grantType = null, $clientId = null);
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ interface SessionInterface extends StorageInterface
|
||||
*
|
||||
* @param \League\OAuth2\Server\Entity\AccessTokenEntity $accessToken The access token
|
||||
*
|
||||
* @return \League\OAuth2\Server\Entity\SessionEntity
|
||||
* @return \League\OAuth2\Server\Entity\SessionEntity | null
|
||||
*/
|
||||
public function getByAccessToken(AccessTokenEntity $accessToken);
|
||||
|
||||
@@ -35,7 +35,7 @@ interface SessionInterface extends StorageInterface
|
||||
*
|
||||
* @param \League\OAuth2\Server\Entity\AuthCodeEntity $authCode The auth code
|
||||
*
|
||||
* @return \League\OAuth2\Server\Entity\SessionEntity
|
||||
* @return \League\OAuth2\Server\Entity\SessionEntity | null
|
||||
*/
|
||||
public function getByAuthCode(AuthCodeEntity $authCode);
|
||||
|
||||
@@ -44,7 +44,7 @@ interface SessionInterface extends StorageInterface
|
||||
*
|
||||
* @param \League\OAuth2\Server\Entity\SessionEntity
|
||||
*
|
||||
* @return array Array of \League\OAuth2\Server\Entity\ScopeEntity
|
||||
* @return \League\OAuth2\Server\Entity\ScopeEntity[] Array of \League\OAuth2\Server\Entity\ScopeEntity
|
||||
*/
|
||||
public function getScopes(SessionEntity $session);
|
||||
|
||||
|
Reference in New Issue
Block a user