aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType')
-rw-r--r--vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/AuthorizationCode.php48
-rw-r--r--vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/ClientCredentials.php35
-rw-r--r--vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/GrantTypeInterface.php41
-rw-r--r--vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/JwtBearer.php47
-rw-r--r--vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/RefreshToken.php63
-rw-r--r--vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/UserCredentials.php46
6 files changed, 248 insertions, 32 deletions
diff --git a/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/AuthorizationCode.php b/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/AuthorizationCode.php
index cae9f787d..784f6b3a3 100644
--- a/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/AuthorizationCode.php
+++ b/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/AuthorizationCode.php
@@ -6,29 +6,47 @@ use OAuth2\Storage\AuthorizationCodeInterface;
use OAuth2\ResponseType\AccessTokenInterface;
use OAuth2\RequestInterface;
use OAuth2\ResponseInterface;
+use Exception;
/**
- *
* @author Brent Shaffer <bshafs at gmail dot com>
*/
class AuthorizationCode implements GrantTypeInterface
{
+ /**
+ * @var AuthorizationCodeInterface
+ */
protected $storage;
+
+ /**
+ * @var array
+ */
protected $authCode;
/**
- * @param \OAuth2\Storage\AuthorizationCodeInterface $storage REQUIRED Storage class for retrieving authorization code information
+ * @param AuthorizationCodeInterface $storage - REQUIRED Storage class for retrieving authorization code information
*/
public function __construct(AuthorizationCodeInterface $storage)
{
$this->storage = $storage;
}
- public function getQuerystringIdentifier()
+ /**
+ * @return string
+ */
+ public function getQueryStringIdentifier()
{
return 'authorization_code';
}
+ /**
+ * Validate the OAuth request
+ *
+ * @param RequestInterface $request
+ * @param ResponseInterface $response
+ * @return bool
+ * @throws Exception
+ */
public function validateRequest(RequestInterface $request, ResponseInterface $response)
{
if (!$request->request('code')) {
@@ -75,21 +93,45 @@ class AuthorizationCode implements GrantTypeInterface
return true;
}
+ /**
+ * Get the client id
+ *
+ * @return mixed
+ */
public function getClientId()
{
return $this->authCode['client_id'];
}
+ /**
+ * Get the scope
+ *
+ * @return string
+ */
public function getScope()
{
return isset($this->authCode['scope']) ? $this->authCode['scope'] : null;
}
+ /**
+ * Get the user id
+ *
+ * @return mixed
+ */
public function getUserId()
{
return isset($this->authCode['user_id']) ? $this->authCode['user_id'] : null;
}
+ /**
+ * Create access token
+ *
+ * @param AccessTokenInterface $accessToken
+ * @param mixed $client_id - client identifier related to the access token.
+ * @param mixed $user_id - user id associated with the access token
+ * @param string $scope - scopes to be stored in space-separated string.
+ * @return array
+ */
public function createAccessToken(AccessTokenInterface $accessToken, $client_id, $user_id, $scope)
{
$token = $accessToken->createAccessToken($client_id, $user_id, $scope);
diff --git a/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/ClientCredentials.php b/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/ClientCredentials.php
index f953e4e8d..e135c2dd2 100644
--- a/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/ClientCredentials.php
+++ b/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/ClientCredentials.php
@@ -9,12 +9,19 @@ use OAuth2\Storage\ClientCredentialsInterface;
/**
* @author Brent Shaffer <bshafs at gmail dot com>
*
- * @see OAuth2\ClientAssertionType_HttpBasic
+ * @see HttpBasic
*/
class ClientCredentials extends HttpBasic implements GrantTypeInterface
{
+ /**
+ * @var array
+ */
private $clientData;
+ /**
+ * @param ClientCredentialsInterface $storage
+ * @param array $config
+ */
public function __construct(ClientCredentialsInterface $storage, array $config = array())
{
/**
@@ -27,11 +34,21 @@ class ClientCredentials extends HttpBasic implements GrantTypeInterface
parent::__construct($storage, $config);
}
- public function getQuerystringIdentifier()
+ /**
+ * Get query string identifier
+ *
+ * @return string
+ */
+ public function getQueryStringIdentifier()
{
return 'client_credentials';
}
+ /**
+ * Get scope
+ *
+ * @return string|null
+ */
public function getScope()
{
$this->loadClientData();
@@ -39,6 +56,11 @@ class ClientCredentials extends HttpBasic implements GrantTypeInterface
return isset($this->clientData['scope']) ? $this->clientData['scope'] : null;
}
+ /**
+ * Get user id
+ *
+ * @return mixed
+ */
public function getUserId()
{
$this->loadClientData();
@@ -46,6 +68,15 @@ class ClientCredentials extends HttpBasic implements GrantTypeInterface
return isset($this->clientData['user_id']) ? $this->clientData['user_id'] : null;
}
+ /**
+ * Create access token
+ *
+ * @param AccessTokenInterface $accessToken
+ * @param mixed $client_id - client identifier related to the access token.
+ * @param mixed $user_id - user id associated with the access token
+ * @param string $scope - scopes to be stored in space-separated string.
+ * @return array
+ */
public function createAccessToken(AccessTokenInterface $accessToken, $client_id, $user_id, $scope)
{
/**
diff --git a/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/GrantTypeInterface.php b/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/GrantTypeInterface.php
index 98489e9c1..f45786ff5 100644
--- a/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/GrantTypeInterface.php
+++ b/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/GrantTypeInterface.php
@@ -11,10 +11,49 @@ use OAuth2\ResponseInterface;
*/
interface GrantTypeInterface
{
- public function getQuerystringIdentifier();
+ /**
+ * Get query string identifier
+ *
+ * @return string
+ */
+ public function getQueryStringIdentifier();
+
+ /**
+ * @param RequestInterface $request
+ * @param ResponseInterface $response
+ * @return mixed
+ */
public function validateRequest(RequestInterface $request, ResponseInterface $response);
+
+ /**
+ * Get client id
+ *
+ * @return mixed
+ */
public function getClientId();
+
+ /**
+ * Get user id
+ *
+ * @return mixed
+ */
public function getUserId();
+
+ /**
+ * Get scope
+ *
+ * @return string|null
+ */
public function getScope();
+
+ /**
+ * Create access token
+ *
+ * @param AccessTokenInterface $accessToken
+ * @param mixed $client_id - client identifier related to the access token.
+ * @param mixed $user_id - user id associated with the access token
+ * @param string $scope - scopes to be stored in space-separated string.
+ * @return array
+ */
public function createAccessToken(AccessTokenInterface $accessToken, $client_id, $user_id, $scope);
}
diff --git a/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/JwtBearer.php b/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/JwtBearer.php
index bb11a6954..62c1efabd 100644
--- a/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/JwtBearer.php
+++ b/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/JwtBearer.php
@@ -30,10 +30,12 @@ class JwtBearer implements GrantTypeInterface, ClientAssertionTypeInterface
/**
* Creates an instance of the JWT bearer grant type.
*
- * @param OAuth2\Storage\JWTBearerInterface|JwtBearerInterface $storage A valid storage interface that implements storage hooks for the JWT bearer grant type.
- * @param string $audience The audience to validate the token against. This is usually the full URI of the OAuth token requests endpoint.
- * @param EncryptionInterface|OAuth2\Encryption\JWT $jwtUtil OPTONAL The class used to decode, encode and verify JWTs.
- * @param array $config
+ * @param JwtBearerInterface $storage - A valid storage interface that implements storage hooks for the JWT
+ * bearer grant type.
+ * @param string $audience - The audience to validate the token against. This is usually the full
+ * URI of the OAuth token requests endpoint.
+ * @param EncryptionInterface|JWT $jwtUtil - OPTONAL The class used to decode, encode and verify JWTs.
+ * @param array $config
*/
public function __construct(JwtBearerInterface $storage, $audience, EncryptionInterface $jwtUtil = null, array $config = array())
{
@@ -56,12 +58,11 @@ class JwtBearer implements GrantTypeInterface, ClientAssertionTypeInterface
/**
* Returns the grant_type get parameter to identify the grant type request as JWT bearer authorization grant.
*
- * @return
- * The string identifier for grant_type.
+ * @return string - The string identifier for grant_type.
*
- * @see OAuth2\GrantType\GrantTypeInterface::getQuerystringIdentifier()
+ * @see GrantTypeInterface::getQueryStringIdentifier()
*/
- public function getQuerystringIdentifier()
+ public function getQueryStringIdentifier()
{
return 'urn:ietf:params:oauth:grant-type:jwt-bearer';
}
@@ -69,10 +70,9 @@ class JwtBearer implements GrantTypeInterface, ClientAssertionTypeInterface
/**
* Validates the data from the decoded JWT.
*
- * @return
- * TRUE if the JWT request is valid and can be decoded. Otherwise, FALSE is returned.
- *
- * @see OAuth2\GrantType\GrantTypeInterface::getTokenData()
+ * @param RequestInterface $request
+ * @param ResponseInterface $response
+ * @return bool|mixed|null TRUE if the JWT request is valid and can be decoded. Otherwise, FALSE is returned.@see GrantTypeInterface::getTokenData()
*/
public function validateRequest(RequestInterface $request, ResponseInterface $response)
{
@@ -196,16 +196,31 @@ class JwtBearer implements GrantTypeInterface, ClientAssertionTypeInterface
return true;
}
+ /**
+ * Get client id
+ *
+ * @return mixed
+ */
public function getClientId()
{
return $this->jwt['iss'];
}
+ /**
+ * Get user id
+ *
+ * @return mixed
+ */
public function getUserId()
{
return $this->jwt['sub'];
}
+ /**
+ * Get scope
+ *
+ * @return null
+ */
public function getScope()
{
return null;
@@ -215,7 +230,13 @@ class JwtBearer implements GrantTypeInterface, ClientAssertionTypeInterface
* Creates an access token that is NOT associated with a refresh token.
* If a subject (sub) the name of the user/account we are accessing data on behalf of.
*
- * @see OAuth2\GrantType\GrantTypeInterface::createAccessToken()
+ * @see GrantTypeInterface::createAccessToken()
+ *
+ * @param AccessTokenInterface $accessToken
+ * @param mixed $client_id - client identifier related to the access token.
+ * @param mixed $user_id - user id associated with the access token
+ * @param string $scope - scopes to be stored in space-separated string.
+ * @return array
*/
public function createAccessToken(AccessTokenInterface $accessToken, $client_id, $user_id, $scope)
{
diff --git a/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/RefreshToken.php b/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/RefreshToken.php
index e55385222..75c611f1d 100644
--- a/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/RefreshToken.php
+++ b/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/RefreshToken.php
@@ -8,25 +8,34 @@ use OAuth2\RequestInterface;
use OAuth2\ResponseInterface;
/**
- *
* @author Brent Shaffer <bshafs at gmail dot com>
*/
class RefreshToken implements GrantTypeInterface
{
+ /**
+ * @var array
+ */
private $refreshToken;
+ /**
+ * @var RefreshTokenInterface
+ */
protected $storage;
+
+ /**
+ * @var array
+ */
protected $config;
/**
- * @param OAuth2\Storage\RefreshTokenInterface $storage REQUIRED Storage class for retrieving refresh token information
- * @param array $config OPTIONAL Configuration options for the server
- * <code>
- * $config = array(
- * 'always_issue_new_refresh_token' => true, // whether to issue a new refresh token upon successful token request
- * 'unset_refresh_token_after_use' => true // whether to unset the refresh token after after using
- * );
- * </code>
+ * @param RefreshTokenInterface $storage - REQUIRED Storage class for retrieving refresh token information
+ * @param array $config - OPTIONAL Configuration options for the server
+ * @code
+ * $config = array(
+ * 'always_issue_new_refresh_token' => true, // whether to issue a new refresh token upon successful token request
+ * 'unset_refresh_token_after_use' => true // whether to unset the refresh token after after using
+ * );
+ * @endcode
*/
public function __construct(RefreshTokenInterface $storage, $config = array())
{
@@ -45,11 +54,21 @@ class RefreshToken implements GrantTypeInterface
$this->storage = $storage;
}
- public function getQuerystringIdentifier()
+ /**
+ * @return string
+ */
+ public function getQueryStringIdentifier()
{
return 'refresh_token';
}
+ /**
+ * Validate the OAuth request
+ *
+ * @param RequestInterface $request
+ * @param ResponseInterface $response
+ * @return bool|mixed|null
+ */
public function validateRequest(RequestInterface $request, ResponseInterface $response)
{
if (!$request->request("refresh_token")) {
@@ -76,21 +95,45 @@ class RefreshToken implements GrantTypeInterface
return true;
}
+ /**
+ * Get client id
+ *
+ * @return mixed
+ */
public function getClientId()
{
return $this->refreshToken['client_id'];
}
+ /**
+ * Get user id
+ *
+ * @return mixed|null
+ */
public function getUserId()
{
return isset($this->refreshToken['user_id']) ? $this->refreshToken['user_id'] : null;
}
+ /**
+ * Get scope
+ *
+ * @return null|string
+ */
public function getScope()
{
return isset($this->refreshToken['scope']) ? $this->refreshToken['scope'] : null;
}
+ /**
+ * Create access token
+ *
+ * @param AccessTokenInterface $accessToken
+ * @param mixed $client_id - client identifier related to the access token.
+ * @param mixed $user_id - user id associated with the access token
+ * @param string $scope - scopes to be stored in space-separated string.
+ * @return array
+ */
public function createAccessToken(AccessTokenInterface $accessToken, $client_id, $user_id, $scope)
{
/*
diff --git a/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/UserCredentials.php b/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/UserCredentials.php
index f165538ba..b10c2dd09 100644
--- a/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/UserCredentials.php
+++ b/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/UserCredentials.php
@@ -6,30 +6,46 @@ use OAuth2\Storage\UserCredentialsInterface;
use OAuth2\ResponseType\AccessTokenInterface;
use OAuth2\RequestInterface;
use OAuth2\ResponseInterface;
+use LogicException;
/**
- *
* @author Brent Shaffer <bshafs at gmail dot com>
*/
class UserCredentials implements GrantTypeInterface
{
+ /**
+ * @var array
+ */
private $userInfo;
+ /**
+ * @var UserCredentialsInterface
+ */
protected $storage;
/**
- * @param OAuth2\Storage\UserCredentialsInterface $storage REQUIRED Storage class for retrieving user credentials information
+ * @param UserCredentialsInterface $storage - REQUIRED Storage class for retrieving user credentials information
*/
public function __construct(UserCredentialsInterface $storage)
{
$this->storage = $storage;
}
- public function getQuerystringIdentifier()
+ /**
+ * @return string
+ */
+ public function getQueryStringIdentifier()
{
return 'password';
}
+ /**
+ * @param RequestInterface $request
+ * @param ResponseInterface $response
+ * @return bool|mixed|null
+ *
+ * @throws LogicException
+ */
public function validateRequest(RequestInterface $request, ResponseInterface $response)
{
if (!$request->request("password") || !$request->request("username")) {
@@ -61,21 +77,45 @@ class UserCredentials implements GrantTypeInterface
return true;
}
+ /**
+ * Get client id
+ *
+ * @return mixed|null
+ */
public function getClientId()
{
return null;
}
+ /**
+ * Get user id
+ *
+ * @return mixed
+ */
public function getUserId()
{
return $this->userInfo['user_id'];
}
+ /**
+ * Get scope
+ *
+ * @return null|string
+ */
public function getScope()
{
return isset($this->userInfo['scope']) ? $this->userInfo['scope'] : null;
}
+ /**
+ * Create access token
+ *
+ * @param AccessTokenInterface $accessToken
+ * @param mixed $client_id - client identifier related to the access token.
+ * @param mixed $user_id - user id associated with the access token
+ * @param string $scope - scopes to be stored in space-separated string.
+ * @return array
+ */
public function createAccessToken(AccessTokenInterface $accessToken, $client_id, $user_id, $scope)
{
return $accessToken->createAccessToken($client_id, $user_id, $scope);