mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-22 21:19:46 +05:30
Merge pull request #502 from juliangut/passphrase
V5 - Handle RSA key passphrase
This commit is contained in:
commit
656a8d7a56
@ -43,7 +43,7 @@ class BearerTokenValidator implements AuthorizationValidatorInterface
|
|||||||
try {
|
try {
|
||||||
// Attempt to parse and validate the JWT
|
// Attempt to parse and validate the JWT
|
||||||
$token = (new Parser())->parse($jwt);
|
$token = (new Parser())->parse($jwt);
|
||||||
if ($token->verify(new Sha256(), $this->publicKeyPath) === false) {
|
if ($token->verify(new Sha256(), $this->publicKey->getKeyPath()) === false) {
|
||||||
throw OAuthServerException::accessDenied('Access token could not be verified');
|
throw OAuthServerException::accessDenied('Access token could not be verified');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
62
src/CryptKey.php
Normal file
62
src/CryptKey.php
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Cryptography key holder.
|
||||||
|
*
|
||||||
|
* @author Julián Gutiérrez <juliangut@gmail.com>
|
||||||
|
* @copyright Copyright (c) Alex Bilbie
|
||||||
|
* @license http://mit-license.org/
|
||||||
|
*
|
||||||
|
* @link https://github.com/thephpleague/oauth2-server
|
||||||
|
*/
|
||||||
|
namespace League\OAuth2\Server;
|
||||||
|
|
||||||
|
class CryptKey
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $keyPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $passPhrase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $keyPath
|
||||||
|
* @param null|string $passPhrase
|
||||||
|
*/
|
||||||
|
public function __construct($keyPath, $passPhrase = null)
|
||||||
|
{
|
||||||
|
if (strpos($keyPath, 'file://') !== 0) {
|
||||||
|
$keyPath = 'file://' . $keyPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file_exists($keyPath) || !is_readable($keyPath)) {
|
||||||
|
throw new \LogicException(sprintf('Key path "%s" does not exist or is not readable', $keyPath));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->keyPath = $keyPath;
|
||||||
|
$this->passPhrase = $passPhrase;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve key path.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getKeyPath()
|
||||||
|
{
|
||||||
|
return $this->keyPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve key pass phrase.
|
||||||
|
*
|
||||||
|
* @return null|string
|
||||||
|
*/
|
||||||
|
public function getPassPhrase()
|
||||||
|
{
|
||||||
|
return $this->passPhrase;
|
||||||
|
}
|
||||||
|
}
|
@ -13,41 +13,33 @@ namespace League\OAuth2\Server;
|
|||||||
trait CryptTrait
|
trait CryptTrait
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var \League\OAuth2\Server\CryptKey
|
||||||
*/
|
*/
|
||||||
protected $privateKeyPath;
|
protected $privateKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var \League\OAuth2\Server\CryptKey
|
||||||
*/
|
*/
|
||||||
protected $publicKeyPath;
|
protected $publicKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set path to private key.
|
* Set path to private key.
|
||||||
*
|
*
|
||||||
* @param string $privateKeyPath
|
* @param \League\OAuth2\Server\CryptKey $privateKey
|
||||||
*/
|
*/
|
||||||
public function setPrivateKeyPath($privateKeyPath)
|
public function setPrivateKey(CryptKey $privateKey)
|
||||||
{
|
{
|
||||||
if (strpos($privateKeyPath, 'file://') !== 0) {
|
$this->privateKey = $privateKey;
|
||||||
$privateKeyPath = 'file://' . $privateKeyPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->privateKeyPath = $privateKeyPath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set path to public key.
|
* Set path to public key.
|
||||||
*
|
*
|
||||||
* @param string $publicKeyPath
|
* @param \League\OAuth2\Server\CryptKey $publicKey
|
||||||
*/
|
*/
|
||||||
public function setPublicKeyPath($publicKeyPath)
|
public function setPublicKey(CryptKey $publicKey)
|
||||||
{
|
{
|
||||||
if (strpos($publicKeyPath, 'file://') !== 0) {
|
$this->publicKey = $publicKey;
|
||||||
$publicKeyPath = 'file://' . $publicKeyPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->publicKeyPath = $publicKeyPath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,10 +51,12 @@ trait CryptTrait
|
|||||||
*/
|
*/
|
||||||
protected function encrypt($unencryptedData)
|
protected function encrypt($unencryptedData)
|
||||||
{
|
{
|
||||||
$privateKey = openssl_pkey_get_private($this->privateKeyPath);
|
$privateKey = openssl_pkey_get_private($this->privateKey->getKeyPath(), $this->privateKey->getPassPhrase());
|
||||||
$privateKeyDetails = @openssl_pkey_get_details($privateKey);
|
$privateKeyDetails = @openssl_pkey_get_details($privateKey);
|
||||||
if ($privateKeyDetails === null) {
|
if ($privateKeyDetails === null) {
|
||||||
throw new \LogicException(sprintf('Could not get details of private key: %s', $this->privateKeyPath));
|
throw new \LogicException(
|
||||||
|
sprintf('Could not get details of private key: %s', $this->privateKey->getKeyPath())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$chunkSize = ceil($privateKeyDetails['bits'] / 8) - 11;
|
$chunkSize = ceil($privateKeyDetails['bits'] / 8) - 11;
|
||||||
@ -78,7 +72,7 @@ trait CryptTrait
|
|||||||
}
|
}
|
||||||
$output .= $encrypted;
|
$output .= $encrypted;
|
||||||
}
|
}
|
||||||
openssl_free_key($privateKey);
|
openssl_pkey_free($privateKey);
|
||||||
|
|
||||||
return base64_encode($output);
|
return base64_encode($output);
|
||||||
}
|
}
|
||||||
@ -94,10 +88,12 @@ trait CryptTrait
|
|||||||
*/
|
*/
|
||||||
protected function decrypt($encryptedData)
|
protected function decrypt($encryptedData)
|
||||||
{
|
{
|
||||||
$publicKey = openssl_pkey_get_public($this->publicKeyPath);
|
$publicKey = openssl_pkey_get_public($this->publicKey->getKeyPath());
|
||||||
$publicKeyDetails = @openssl_pkey_get_details($publicKey);
|
$publicKeyDetails = @openssl_pkey_get_details($publicKey);
|
||||||
if ($publicKeyDetails === null) {
|
if ($publicKeyDetails === null) {
|
||||||
throw new \LogicException(sprintf('Could not get details of public key: %s', $this->publicKeyPath));
|
throw new \LogicException(
|
||||||
|
sprintf('Could not get details of public key: %s', $this->publicKey->getKeyPath())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$chunkSize = ceil($publicKeyDetails['bits'] / 8);
|
$chunkSize = ceil($publicKeyDetails['bits'] / 8);
|
||||||
@ -115,7 +111,7 @@ trait CryptTrait
|
|||||||
}
|
}
|
||||||
$output .= $decrypted;
|
$output .= $decrypted;
|
||||||
}
|
}
|
||||||
openssl_free_key($publicKey);
|
openssl_pkey_free($publicKey);
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ namespace League\OAuth2\Server\Entities;
|
|||||||
use Lcobucci\JWT\Builder;
|
use Lcobucci\JWT\Builder;
|
||||||
use Lcobucci\JWT\Signer\Key;
|
use Lcobucci\JWT\Signer\Key;
|
||||||
use Lcobucci\JWT\Signer\Rsa\Sha256;
|
use Lcobucci\JWT\Signer\Rsa\Sha256;
|
||||||
|
use League\OAuth2\Server\CryptKey;
|
||||||
use League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface;
|
use League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface;
|
||||||
use League\OAuth2\Server\Entities\Traits\EntityTrait;
|
use League\OAuth2\Server\Entities\Traits\EntityTrait;
|
||||||
use League\OAuth2\Server\Entities\Traits\TokenEntityTrait;
|
use League\OAuth2\Server\Entities\Traits\TokenEntityTrait;
|
||||||
@ -16,11 +17,11 @@ class AccessTokenEntity implements AccessTokenEntityInterface
|
|||||||
/**
|
/**
|
||||||
* Generate a JWT from the access token
|
* Generate a JWT from the access token
|
||||||
*
|
*
|
||||||
* @param string $privateKeyPath
|
* @param \League\OAuth2\Server\CryptKey $privateKey
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function convertToJWT($privateKeyPath)
|
public function convertToJWT(CryptKey $privateKey)
|
||||||
{
|
{
|
||||||
return (new Builder())
|
return (new Builder())
|
||||||
->setAudience($this->getClient()->getIdentifier())
|
->setAudience($this->getClient()->getIdentifier())
|
||||||
@ -30,7 +31,7 @@ class AccessTokenEntity implements AccessTokenEntityInterface
|
|||||||
->setExpiration($this->getExpiryDateTime()->getTimestamp())
|
->setExpiration($this->getExpiryDateTime()->getTimestamp())
|
||||||
->setSubject($this->getUserIdentifier())
|
->setSubject($this->getUserIdentifier())
|
||||||
->set('scopes', $this->getScopes())
|
->set('scopes', $this->getScopes())
|
||||||
->sign(new Sha256(), new Key($privateKeyPath))
|
->sign(new Sha256(), new Key($privateKey->getKeyPath(), $privateKey->getPassPhrase()))
|
||||||
->getToken();
|
->getToken();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,14 +2,16 @@
|
|||||||
|
|
||||||
namespace League\OAuth2\Server\Entities\Interfaces;
|
namespace League\OAuth2\Server\Entities\Interfaces;
|
||||||
|
|
||||||
|
use League\OAuth2\Server\CryptKey;
|
||||||
|
|
||||||
interface AccessTokenEntityInterface extends TokenInterface
|
interface AccessTokenEntityInterface extends TokenInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Generate a JWT from the access token
|
* Generate a JWT from the access token
|
||||||
*
|
*
|
||||||
* @param string $privateKeyPath
|
* @param \League\OAuth2\Server\CryptKey $privateKey
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function convertToJWT($privateKeyPath);
|
public function convertToJWT(CryptKey $privateKey);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
namespace League\OAuth2\Server\Grant;
|
namespace League\OAuth2\Server\Grant;
|
||||||
|
|
||||||
use League\Event\EmitterAwareInterface;
|
use League\Event\EmitterAwareInterface;
|
||||||
|
use League\OAuth2\Server\CryptKey;
|
||||||
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
|
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
|
||||||
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
|
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
|
||||||
use League\OAuth2\Server\Repositories\ScopeRepositoryInterface;
|
use League\OAuth2\Server\Repositories\ScopeRepositoryInterface;
|
||||||
@ -89,14 +90,14 @@ interface GrantTypeInterface extends EmitterAwareInterface
|
|||||||
/**
|
/**
|
||||||
* Set the path to the private key.
|
* Set the path to the private key.
|
||||||
*
|
*
|
||||||
* @param string $privateKeyPath
|
* @param \League\OAuth2\Server\CryptKey $privateKey
|
||||||
*/
|
*/
|
||||||
public function setPrivateKeyPath($privateKeyPath);
|
public function setPrivateKey(CryptKey $privateKey);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the path to the public key.
|
* Set the path to the public key.
|
||||||
*
|
*
|
||||||
* @param string $publicKeyPath
|
* @param \League\OAuth2\Server\CryptKey $publicKey
|
||||||
*/
|
*/
|
||||||
public function setPublicKeyPath($publicKeyPath);
|
public function setPublicKey(CryptKey $publicKey);
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ class ImplicitGrant extends AbstractAuthorizeGrant
|
|||||||
$scopes
|
$scopes
|
||||||
);
|
);
|
||||||
|
|
||||||
$redirectPayload['access_token'] = (string) $accessToken->convertToJWT($this->privateKeyPath);
|
$redirectPayload['access_token'] = (string) $accessToken->convertToJWT($this->privateKey);
|
||||||
$redirectPayload['token_type'] = 'bearer';
|
$redirectPayload['token_type'] = 'bearer';
|
||||||
$redirectPayload['expires_in'] = time() - $accessToken->getExpiryDateTime()->getTimestamp();
|
$redirectPayload['expires_in'] = time() - $accessToken->getExpiryDateTime()->getTimestamp();
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class BearerTokenResponse extends AbstractResponseType
|
|||||||
{
|
{
|
||||||
$expireDateTime = $this->accessToken->getExpiryDateTime()->getTimestamp();
|
$expireDateTime = $this->accessToken->getExpiryDateTime()->getTimestamp();
|
||||||
|
|
||||||
$jwtAccessToken = $this->accessToken->convertToJWT($this->privateKeyPath);
|
$jwtAccessToken = $this->accessToken->convertToJWT($this->privateKey);
|
||||||
|
|
||||||
$responseParams = [
|
$responseParams = [
|
||||||
'token_type' => 'Bearer',
|
'token_type' => 'Bearer',
|
||||||
|
@ -32,20 +32,20 @@ class Server implements EmitterAwareInterface
|
|||||||
protected $grantTypeAccessTokenTTL = [];
|
protected $grantTypeAccessTokenTTL = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var \League\OAuth2\Server\CryptKey
|
||||||
*/
|
*/
|
||||||
protected $privateKeyPath;
|
protected $privateKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \League\OAuth2\Server\CryptKey
|
||||||
|
*/
|
||||||
|
protected $publicKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ResponseTypeInterface
|
* @var ResponseTypeInterface
|
||||||
*/
|
*/
|
||||||
protected $responseType;
|
protected $responseType;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $publicKeyPath;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \League\OAuth2\Server\Repositories\ClientRepositoryInterface
|
* @var \League\OAuth2\Server\Repositories\ClientRepositoryInterface
|
||||||
*/
|
*/
|
||||||
@ -72,8 +72,8 @@ class Server implements EmitterAwareInterface
|
|||||||
* @param \League\OAuth2\Server\Repositories\ClientRepositoryInterface $clientRepository
|
* @param \League\OAuth2\Server\Repositories\ClientRepositoryInterface $clientRepository
|
||||||
* @param \League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface $accessTokenRepository
|
* @param \League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface $accessTokenRepository
|
||||||
* @param \League\OAuth2\Server\Repositories\ScopeRepositoryInterface $scopeRepository
|
* @param \League\OAuth2\Server\Repositories\ScopeRepositoryInterface $scopeRepository
|
||||||
* @param string $privateKeyPath
|
* @param \League\OAuth2\Server\CryptKey|string $privateKey
|
||||||
* @param string $publicKeyPath
|
* @param \League\OAuth2\Server\CryptKey|string $publicKey
|
||||||
* @param null|\League\OAuth2\Server\ResponseTypes\ResponseTypeInterface $responseType
|
* @param null|\League\OAuth2\Server\ResponseTypes\ResponseTypeInterface $responseType
|
||||||
* @param null|\League\OAuth2\Server\AuthorizationValidators\AuthorizationValidatorInterface $authorizationValidator
|
* @param null|\League\OAuth2\Server\AuthorizationValidators\AuthorizationValidatorInterface $authorizationValidator
|
||||||
*/
|
*/
|
||||||
@ -81,16 +81,25 @@ class Server implements EmitterAwareInterface
|
|||||||
ClientRepositoryInterface $clientRepository,
|
ClientRepositoryInterface $clientRepository,
|
||||||
AccessTokenRepositoryInterface $accessTokenRepository,
|
AccessTokenRepositoryInterface $accessTokenRepository,
|
||||||
ScopeRepositoryInterface $scopeRepository,
|
ScopeRepositoryInterface $scopeRepository,
|
||||||
$privateKeyPath,
|
$privateKey,
|
||||||
$publicKeyPath,
|
$publicKey,
|
||||||
ResponseTypeInterface $responseType = null,
|
ResponseTypeInterface $responseType = null,
|
||||||
AuthorizationValidatorInterface $authorizationValidator = null
|
AuthorizationValidatorInterface $authorizationValidator = null
|
||||||
) {
|
) {
|
||||||
$this->clientRepository = $clientRepository;
|
$this->clientRepository = $clientRepository;
|
||||||
$this->accessTokenRepository = $accessTokenRepository;
|
$this->accessTokenRepository = $accessTokenRepository;
|
||||||
$this->scopeRepository = $scopeRepository;
|
$this->scopeRepository = $scopeRepository;
|
||||||
$this->privateKeyPath = $privateKeyPath;
|
|
||||||
$this->publicKeyPath = $publicKeyPath;
|
if (!$privateKey instanceof CryptKey) {
|
||||||
|
$privateKey = new CryptKey($privateKey);
|
||||||
|
}
|
||||||
|
$this->privateKey = $privateKey;
|
||||||
|
|
||||||
|
if (!$publicKey instanceof CryptKey) {
|
||||||
|
$publicKey = new CryptKey($publicKey);
|
||||||
|
}
|
||||||
|
$this->publicKey = $publicKey;
|
||||||
|
|
||||||
$this->responseType = $responseType;
|
$this->responseType = $responseType;
|
||||||
$this->authorizationValidator = $authorizationValidator;
|
$this->authorizationValidator = $authorizationValidator;
|
||||||
}
|
}
|
||||||
@ -106,8 +115,8 @@ class Server implements EmitterAwareInterface
|
|||||||
$grantType->setAccessTokenRepository($this->accessTokenRepository);
|
$grantType->setAccessTokenRepository($this->accessTokenRepository);
|
||||||
$grantType->setClientRepository($this->clientRepository);
|
$grantType->setClientRepository($this->clientRepository);
|
||||||
$grantType->setScopeRepository($this->scopeRepository);
|
$grantType->setScopeRepository($this->scopeRepository);
|
||||||
$grantType->setPrivateKeyPath($this->privateKeyPath);
|
$grantType->setPrivateKey($this->privateKey);
|
||||||
$grantType->setPublicKeyPath($this->publicKeyPath);
|
$grantType->setPublicKey($this->publicKey);
|
||||||
$grantType->setEmitter($this->getEmitter());
|
$grantType->setEmitter($this->getEmitter());
|
||||||
|
|
||||||
$this->enabledGrantTypes[$grantType->getIdentifier()] = $grantType;
|
$this->enabledGrantTypes[$grantType->getIdentifier()] = $grantType;
|
||||||
@ -118,8 +127,8 @@ class Server implements EmitterAwareInterface
|
|||||||
/**
|
/**
|
||||||
* Return an access token response.
|
* Return an access token response.
|
||||||
*
|
*
|
||||||
* @param \Psr\Http\Message\ServerRequestInterface|null $request
|
* @param \Psr\Http\Message\ServerRequestInterface $request
|
||||||
* @param \Psr\Http\Message\ResponseInterface|null $response
|
* @param \Psr\Http\Message\ResponseInterface $response
|
||||||
*
|
*
|
||||||
* @throws \League\OAuth2\Server\Exception\OAuthServerException
|
* @throws \League\OAuth2\Server\Exception\OAuthServerException
|
||||||
*
|
*
|
||||||
@ -171,8 +180,7 @@ class Server implements EmitterAwareInterface
|
|||||||
$this->responseType = new BearerTokenResponse($this->accessTokenRepository);
|
$this->responseType = new BearerTokenResponse($this->accessTokenRepository);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->responseType->setPublicKeyPath($this->publicKeyPath);
|
$this->responseType->setPrivateKey($this->privateKey);
|
||||||
$this->responseType->setPrivateKeyPath($this->privateKeyPath);
|
|
||||||
|
|
||||||
return $this->responseType;
|
return $this->responseType;
|
||||||
}
|
}
|
||||||
@ -186,8 +194,7 @@ class Server implements EmitterAwareInterface
|
|||||||
$this->authorizationValidator = new BearerTokenValidator($this->accessTokenRepository);
|
$this->authorizationValidator = new BearerTokenValidator($this->accessTokenRepository);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->authorizationValidator->setPublicKeyPath($this->publicKeyPath);
|
$this->authorizationValidator->setPublicKey($this->publicKey);
|
||||||
$this->authorizationValidator->setPrivateKeyPath($this->privateKeyPath);
|
|
||||||
|
|
||||||
return $this->authorizationValidator;
|
return $this->authorizationValidator;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace LeagueTests\Utils;
|
namespace LeagueTests\Utils;
|
||||||
|
|
||||||
|
use League\OAuth2\Server\CryptKey;
|
||||||
use LeagueTests\Stubs\CryptTraitStub;
|
use LeagueTests\Stubs\CryptTraitStub;
|
||||||
|
|
||||||
class CryptTraitTest extends \PHPUnit_Framework_TestCase
|
class CryptTraitTest extends \PHPUnit_Framework_TestCase
|
||||||
@ -31,7 +32,7 @@ class CryptTraitTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testBadPrivateKey()
|
public function testBadPrivateKey()
|
||||||
{
|
{
|
||||||
$this->cryptStub->setPrivateKeyPath(__DIR__ . '/Stubs/public.key');
|
$this->cryptStub->setPrivateKey(new CryptKey(__DIR__ . '/Stubs/public.key'));
|
||||||
$this->cryptStub->doEncrypt('');
|
$this->cryptStub->doEncrypt('');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +41,7 @@ class CryptTraitTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testBadPublicKey()
|
public function testBadPublicKey()
|
||||||
{
|
{
|
||||||
$this->cryptStub->setPublicKeyPath(__DIR__ . '/Stubs/private.key');
|
$this->cryptStub->setPublicKey(new CryptKey(__DIR__ . '/Stubs/private.key'));
|
||||||
$this->cryptStub->doDecrypt('');
|
$this->cryptStub->doDecrypt('');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace LeagueTests\Grant;
|
namespace LeagueTests\Grant;
|
||||||
|
|
||||||
use League\Event\Emitter;
|
use League\Event\Emitter;
|
||||||
|
use League\OAuth2\Server\CryptKey;
|
||||||
use League\OAuth2\Server\Entities\AccessTokenEntity;
|
use League\OAuth2\Server\Entities\AccessTokenEntity;
|
||||||
use League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface;
|
use League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface;
|
||||||
use League\OAuth2\Server\Entities\Interfaces\AuthCodeEntityInterface;
|
use League\OAuth2\Server\Entities\Interfaces\AuthCodeEntityInterface;
|
||||||
@ -23,8 +24,8 @@ class AbstractGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
/** @var AbstractGrant $grantMock */
|
/** @var AbstractGrant $grantMock */
|
||||||
$grantMock = $this->getMockForAbstractClass(AbstractGrant::class);
|
$grantMock = $this->getMockForAbstractClass(AbstractGrant::class);
|
||||||
$grantMock->setPrivateKeyPath('./private.key');
|
$grantMock->setPrivateKey(new CryptKey(__DIR__ . '/../Stubs/private.key'));
|
||||||
$grantMock->setPublicKeyPath('./public.key');
|
$grantMock->setPublicKey(new CryptKey(__DIR__ . '/../Stubs/public.key'));
|
||||||
$grantMock->setEmitter(new Emitter());
|
$grantMock->setEmitter(new Emitter());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace LeagueTests\Grant;
|
namespace LeagueTests\Grant;
|
||||||
|
|
||||||
|
use League\OAuth2\Server\CryptKey;
|
||||||
use League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface;
|
use League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface;
|
||||||
use League\OAuth2\Server\Entities\Interfaces\RefreshTokenEntityInterface;
|
use League\OAuth2\Server\Entities\Interfaces\RefreshTokenEntityInterface;
|
||||||
use League\OAuth2\Server\Exception\OAuthServerException;
|
use League\OAuth2\Server\Exception\OAuthServerException;
|
||||||
@ -99,8 +100,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
$grant->setScopeRepository($scopeRepositoryMock);
|
$grant->setScopeRepository($scopeRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest(
|
$request = new ServerRequest(
|
||||||
[
|
[
|
||||||
@ -161,8 +162,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
);
|
);
|
||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest(
|
$request = new ServerRequest(
|
||||||
[
|
[
|
||||||
@ -214,8 +215,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
new \DateInterval('PT10M')
|
new \DateInterval('PT10M')
|
||||||
);
|
);
|
||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest(
|
$request = new ServerRequest(
|
||||||
[
|
[
|
||||||
@ -260,8 +261,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
new \DateInterval('PT10M')
|
new \DateInterval('PT10M')
|
||||||
);
|
);
|
||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest(
|
$request = new ServerRequest(
|
||||||
[
|
[
|
||||||
@ -312,8 +313,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
new \DateInterval('PT10M')
|
new \DateInterval('PT10M')
|
||||||
);
|
);
|
||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest(
|
$request = new ServerRequest(
|
||||||
[
|
[
|
||||||
@ -370,8 +371,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
new \DateInterval('PT10M')
|
new \DateInterval('PT10M')
|
||||||
);
|
);
|
||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest(
|
$request = new ServerRequest(
|
||||||
[
|
[
|
||||||
@ -426,8 +427,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
$grant->setScopeRepository($scopeRepositoryMock);
|
$grant->setScopeRepository($scopeRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest(
|
$request = new ServerRequest(
|
||||||
[
|
[
|
||||||
@ -483,8 +484,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
);
|
);
|
||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest(
|
$request = new ServerRequest(
|
||||||
[
|
[
|
||||||
@ -542,8 +543,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
);
|
);
|
||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest(
|
$request = new ServerRequest(
|
||||||
[
|
[
|
||||||
@ -607,8 +608,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$grant->setScopeRepository($scopeRepositoryMock);
|
$grant->setScopeRepository($scopeRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
$grant->setRefreshTokenRepository($refreshTokenRepositoryMock);
|
$grant->setRefreshTokenRepository($refreshTokenRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest(
|
$request = new ServerRequest(
|
||||||
[],
|
[],
|
||||||
@ -665,8 +666,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
$grant->setRefreshTokenRepository($refreshTokenRepositoryMock);
|
$grant->setRefreshTokenRepository($refreshTokenRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest(
|
$request = new ServerRequest(
|
||||||
[],
|
[],
|
||||||
@ -711,8 +712,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
$grant->setRefreshTokenRepository($refreshTokenRepositoryMock);
|
$grant->setRefreshTokenRepository($refreshTokenRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest(
|
$request = new ServerRequest(
|
||||||
[],
|
[],
|
||||||
@ -762,8 +763,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
$grant->setRefreshTokenRepository($refreshTokenRepositoryMock);
|
$grant->setRefreshTokenRepository($refreshTokenRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest(
|
$request = new ServerRequest(
|
||||||
[],
|
[],
|
||||||
@ -831,8 +832,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
$grant->setRefreshTokenRepository($refreshTokenRepositoryMock);
|
$grant->setRefreshTokenRepository($refreshTokenRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest(
|
$request = new ServerRequest(
|
||||||
[],
|
[],
|
||||||
@ -897,8 +898,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
$grant->setRefreshTokenRepository($refreshTokenRepositoryMock);
|
$grant->setRefreshTokenRepository($refreshTokenRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest(
|
$request = new ServerRequest(
|
||||||
[],
|
[],
|
||||||
@ -963,8 +964,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
$grant->setRefreshTokenRepository($refreshTokenRepositoryMock);
|
$grant->setRefreshTokenRepository($refreshTokenRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest(
|
$request = new ServerRequest(
|
||||||
[],
|
[],
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace LeagueTests\Grant;
|
namespace LeagueTests\Grant;
|
||||||
|
|
||||||
|
use League\OAuth2\Server\CryptKey;
|
||||||
use League\OAuth2\Server\Exception\OAuthServerException;
|
use League\OAuth2\Server\Exception\OAuthServerException;
|
||||||
use League\OAuth2\Server\Grant\ImplicitGrant;
|
use League\OAuth2\Server\Grant\ImplicitGrant;
|
||||||
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
|
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
|
||||||
@ -77,8 +78,8 @@ class ImplicitGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
$grant->setScopeRepository($scopeRepositoryMock);
|
$grant->setScopeRepository($scopeRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest(
|
$request = new ServerRequest(
|
||||||
[
|
[
|
||||||
@ -115,8 +116,8 @@ class ImplicitGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testRespondToAuthorizationRequestMissingClientId()
|
public function testRespondToAuthorizationRequestMissingClientId()
|
||||||
{
|
{
|
||||||
$grant = new ImplicitGrant($this->getMock(UserRepositoryInterface::class));
|
$grant = new ImplicitGrant($this->getMock(UserRepositoryInterface::class));
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest(
|
$request = new ServerRequest(
|
||||||
[
|
[
|
||||||
@ -152,8 +153,8 @@ class ImplicitGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$grant = new ImplicitGrant($this->getMock(UserRepositoryInterface::class));
|
$grant = new ImplicitGrant($this->getMock(UserRepositoryInterface::class));
|
||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest(
|
$request = new ServerRequest(
|
||||||
[
|
[
|
||||||
@ -199,8 +200,8 @@ class ImplicitGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$grant = new ImplicitGrant($this->getMock(UserRepositoryInterface::class));
|
$grant = new ImplicitGrant($this->getMock(UserRepositoryInterface::class));
|
||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest(
|
$request = new ServerRequest(
|
||||||
[
|
[
|
||||||
@ -252,8 +253,8 @@ class ImplicitGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$grant = new ImplicitGrant($this->getMock(UserRepositoryInterface::class));
|
$grant = new ImplicitGrant($this->getMock(UserRepositoryInterface::class));
|
||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest(
|
$request = new ServerRequest(
|
||||||
[
|
[
|
||||||
@ -299,8 +300,8 @@ class ImplicitGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$grant = new ImplicitGrant($this->getMock(UserRepositoryInterface::class));
|
$grant = new ImplicitGrant($this->getMock(UserRepositoryInterface::class));
|
||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest(
|
$request = new ServerRequest(
|
||||||
[
|
[
|
||||||
@ -350,8 +351,8 @@ class ImplicitGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$grant = new ImplicitGrant($this->getMock(UserRepositoryInterface::class));
|
$grant = new ImplicitGrant($this->getMock(UserRepositoryInterface::class));
|
||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest(
|
$request = new ServerRequest(
|
||||||
[
|
[
|
||||||
@ -401,8 +402,8 @@ class ImplicitGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$grant = new ImplicitGrant($this->getMock(UserRepositoryInterface::class));
|
$grant = new ImplicitGrant($this->getMock(UserRepositoryInterface::class));
|
||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest(
|
$request = new ServerRequest(
|
||||||
[
|
[
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace LeagueTests\Grant;
|
namespace LeagueTests\Grant;
|
||||||
|
|
||||||
|
use League\OAuth2\Server\CryptKey;
|
||||||
use League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface;
|
use League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface;
|
||||||
use League\OAuth2\Server\Entities\Interfaces\RefreshTokenEntityInterface;
|
use League\OAuth2\Server\Entities\Interfaces\RefreshTokenEntityInterface;
|
||||||
use League\OAuth2\Server\Grant\RefreshTokenGrant;
|
use League\OAuth2\Server\Grant\RefreshTokenGrant;
|
||||||
@ -61,8 +62,8 @@ class RefreshTokenGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setScopeRepository($scopeRepositoryMock);
|
$grant->setScopeRepository($scopeRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$oldRefreshToken = $this->cryptStub->doEncrypt(
|
$oldRefreshToken = $this->cryptStub->doEncrypt(
|
||||||
json_encode(
|
json_encode(
|
||||||
@ -116,8 +117,8 @@ class RefreshTokenGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
$grant->setScopeRepository($scopeRepositoryMock);
|
$grant->setScopeRepository($scopeRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$oldRefreshToken = $this->cryptStub->doEncrypt(
|
$oldRefreshToken = $this->cryptStub->doEncrypt(
|
||||||
json_encode(
|
json_encode(
|
||||||
@ -176,8 +177,8 @@ class RefreshTokenGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
$grant->setScopeRepository($scopeRepositoryMock);
|
$grant->setScopeRepository($scopeRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$oldRefreshToken = $this->cryptStub->doEncrypt(
|
$oldRefreshToken = $this->cryptStub->doEncrypt(
|
||||||
json_encode(
|
json_encode(
|
||||||
@ -224,8 +225,8 @@ class RefreshTokenGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$grant = new RefreshTokenGrant($refreshTokenRepositoryMock);
|
$grant = new RefreshTokenGrant($refreshTokenRepositoryMock);
|
||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$serverRequest = new ServerRequest();
|
$serverRequest = new ServerRequest();
|
||||||
$serverRequest = $serverRequest->withParsedBody(
|
$serverRequest = $serverRequest->withParsedBody(
|
||||||
@ -257,8 +258,8 @@ class RefreshTokenGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$grant = new RefreshTokenGrant($refreshTokenRepositoryMock);
|
$grant = new RefreshTokenGrant($refreshTokenRepositoryMock);
|
||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$oldRefreshToken = 'foobar';
|
$oldRefreshToken = 'foobar';
|
||||||
|
|
||||||
@ -297,8 +298,8 @@ class RefreshTokenGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$grant = new RefreshTokenGrant($refreshTokenRepositoryMock);
|
$grant = new RefreshTokenGrant($refreshTokenRepositoryMock);
|
||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$oldRefreshToken = $this->cryptStub->doEncrypt(
|
$oldRefreshToken = $this->cryptStub->doEncrypt(
|
||||||
json_encode(
|
json_encode(
|
||||||
@ -344,8 +345,8 @@ class RefreshTokenGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$grant = new RefreshTokenGrant($refreshTokenRepositoryMock);
|
$grant = new RefreshTokenGrant($refreshTokenRepositoryMock);
|
||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$oldRefreshToken = $this->cryptStub->doEncrypt(
|
$oldRefreshToken = $this->cryptStub->doEncrypt(
|
||||||
json_encode(
|
json_encode(
|
||||||
@ -392,8 +393,8 @@ class RefreshTokenGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$grant = new RefreshTokenGrant($refreshTokenRepositoryMock);
|
$grant = new RefreshTokenGrant($refreshTokenRepositoryMock);
|
||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$oldRefreshToken = $this->cryptStub->doEncrypt(
|
$oldRefreshToken = $this->cryptStub->doEncrypt(
|
||||||
json_encode(
|
json_encode(
|
||||||
|
@ -27,8 +27,8 @@ class AuthenticationServerMiddlewareTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientRepository,
|
$clientRepository,
|
||||||
$this->getMock(AccessTokenRepositoryInterface::class),
|
$this->getMock(AccessTokenRepositoryInterface::class),
|
||||||
$scopeRepositoryMock,
|
$scopeRepositoryMock,
|
||||||
'',
|
'file://' . __DIR__ . '/../Stubs/private.key',
|
||||||
'',
|
'file://' . __DIR__ . '/../Stubs/public.key',
|
||||||
new StubResponseType()
|
new StubResponseType()
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -60,8 +60,8 @@ class AuthenticationServerMiddlewareTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientRepository,
|
$clientRepository,
|
||||||
$this->getMock(AccessTokenRepositoryInterface::class),
|
$this->getMock(AccessTokenRepositoryInterface::class),
|
||||||
$this->getMock(ScopeRepositoryInterface::class),
|
$this->getMock(ScopeRepositoryInterface::class),
|
||||||
'',
|
'file://' . __DIR__ . '/../Stubs/private.key',
|
||||||
'',
|
'file://' . __DIR__ . '/../Stubs/public.key',
|
||||||
new StubResponseType()
|
new StubResponseType()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace LeagueTests\Middleware;
|
namespace LeagueTests\Middleware;
|
||||||
|
|
||||||
|
use League\OAuth2\Server\CryptKey;
|
||||||
use League\OAuth2\Server\Entities\AccessTokenEntity;
|
use League\OAuth2\Server\Entities\AccessTokenEntity;
|
||||||
use League\OAuth2\Server\Middleware\ResourceServerMiddleware;
|
use League\OAuth2\Server\Middleware\ResourceServerMiddleware;
|
||||||
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
|
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
|
||||||
@ -37,7 +38,7 @@ class ResourceServerMiddlewareTest extends \PHPUnit_Framework_TestCase
|
|||||||
$accessToken->setExpiryDateTime((new \DateTime())->add(new \DateInterval('PT1H')));
|
$accessToken->setExpiryDateTime((new \DateTime())->add(new \DateInterval('PT1H')));
|
||||||
$accessToken->setClient($client);
|
$accessToken->setClient($client);
|
||||||
|
|
||||||
$token = $accessToken->convertToJWT('file://' . __DIR__ . '/../Stubs/private.key');
|
$token = $accessToken->convertToJWT(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
|
|
||||||
$request = new ServerRequest();
|
$request = new ServerRequest();
|
||||||
$request = $request->withHeader('authorization', sprintf('Bearer %s', $token));
|
$request = $request->withHeader('authorization', sprintf('Bearer %s', $token));
|
||||||
@ -64,8 +65,8 @@ class ResourceServerMiddlewareTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientRepository,
|
$clientRepository,
|
||||||
$this->getMock(AccessTokenRepositoryInterface::class),
|
$this->getMock(AccessTokenRepositoryInterface::class),
|
||||||
$this->getMock(ScopeRepositoryInterface::class),
|
$this->getMock(ScopeRepositoryInterface::class),
|
||||||
'',
|
'file://' . __DIR__ . '/../Stubs/private.key',
|
||||||
'',
|
'file://' . __DIR__ . '/../Stubs/public.key',
|
||||||
new StubResponseType()
|
new StubResponseType()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace LeagueTests\ResponseTypes;
|
namespace LeagueTests\ResponseTypes;
|
||||||
|
|
||||||
use League\OAuth2\Server\AuthorizationValidators\BearerTokenValidator;
|
use League\OAuth2\Server\AuthorizationValidators\BearerTokenValidator;
|
||||||
|
use League\OAuth2\Server\CryptKey;
|
||||||
use League\OAuth2\Server\Entities\AccessTokenEntity;
|
use League\OAuth2\Server\Entities\AccessTokenEntity;
|
||||||
use League\OAuth2\Server\Entities\RefreshTokenEntity;
|
use League\OAuth2\Server\Entities\RefreshTokenEntity;
|
||||||
use League\OAuth2\Server\Exception\OAuthServerException;
|
use League\OAuth2\Server\Exception\OAuthServerException;
|
||||||
@ -21,8 +22,8 @@ class BearerResponseTypeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
||||||
|
|
||||||
$responseType = new BearerTokenResponse($accessTokenRepositoryMock);
|
$responseType = new BearerTokenResponse($accessTokenRepositoryMock);
|
||||||
$responseType->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$responseType->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
$responseType->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$responseType->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
|
|
||||||
$client = new ClientEntity();
|
$client = new ClientEntity();
|
||||||
$client->setIdentifier('clientName');
|
$client->setIdentifier('clientName');
|
||||||
@ -66,8 +67,8 @@ class BearerResponseTypeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$accessTokenRepositoryMock->method('isAccessTokenRevoked')->willReturn(false);
|
$accessTokenRepositoryMock->method('isAccessTokenRevoked')->willReturn(false);
|
||||||
|
|
||||||
$responseType = new BearerTokenResponse($accessTokenRepositoryMock);
|
$responseType = new BearerTokenResponse($accessTokenRepositoryMock);
|
||||||
$responseType->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$responseType->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
$responseType->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$responseType->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
|
|
||||||
$client = new ClientEntity();
|
$client = new ClientEntity();
|
||||||
$client->setIdentifier('clientName');
|
$client->setIdentifier('clientName');
|
||||||
@ -90,8 +91,8 @@ class BearerResponseTypeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$json = json_decode((string) $response->getBody());
|
$json = json_decode((string) $response->getBody());
|
||||||
|
|
||||||
$authorizationValidator = new BearerTokenValidator($accessTokenRepositoryMock);
|
$authorizationValidator = new BearerTokenValidator($accessTokenRepositoryMock);
|
||||||
$authorizationValidator->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$authorizationValidator->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
$authorizationValidator->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$authorizationValidator->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
|
|
||||||
$request = new ServerRequest();
|
$request = new ServerRequest();
|
||||||
$request = $request->withHeader('authorization', sprintf('Bearer %s', $json->access_token));
|
$request = $request->withHeader('authorization', sprintf('Bearer %s', $json->access_token));
|
||||||
@ -110,8 +111,8 @@ class BearerResponseTypeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$accessTokenRepositoryMock->method('isAccessTokenRevoked')->willReturn(false);
|
$accessTokenRepositoryMock->method('isAccessTokenRevoked')->willReturn(false);
|
||||||
|
|
||||||
$responseType = new BearerTokenResponse($accessTokenRepositoryMock);
|
$responseType = new BearerTokenResponse($accessTokenRepositoryMock);
|
||||||
$responseType->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$responseType->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
$responseType->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$responseType->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
|
|
||||||
$client = new ClientEntity();
|
$client = new ClientEntity();
|
||||||
$client->setIdentifier('clientName');
|
$client->setIdentifier('clientName');
|
||||||
@ -134,8 +135,8 @@ class BearerResponseTypeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$json = json_decode((string) $response->getBody());
|
$json = json_decode((string) $response->getBody());
|
||||||
|
|
||||||
$authorizationValidator = new BearerTokenValidator($accessTokenRepositoryMock);
|
$authorizationValidator = new BearerTokenValidator($accessTokenRepositoryMock);
|
||||||
$authorizationValidator->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$authorizationValidator->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
$authorizationValidator->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$authorizationValidator->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
|
|
||||||
$request = new ServerRequest();
|
$request = new ServerRequest();
|
||||||
$request = $request->withHeader('authorization', sprintf('Bearer %s', $json->access_token . 'foo'));
|
$request = $request->withHeader('authorization', sprintf('Bearer %s', $json->access_token . 'foo'));
|
||||||
@ -156,8 +157,8 @@ class BearerResponseTypeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$accessTokenRepositoryMock->method('isAccessTokenRevoked')->willReturn(true);
|
$accessTokenRepositoryMock->method('isAccessTokenRevoked')->willReturn(true);
|
||||||
|
|
||||||
$responseType = new BearerTokenResponse($accessTokenRepositoryMock);
|
$responseType = new BearerTokenResponse($accessTokenRepositoryMock);
|
||||||
$responseType->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$responseType->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
$responseType->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$responseType->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
|
|
||||||
$client = new ClientEntity();
|
$client = new ClientEntity();
|
||||||
$client->setIdentifier('clientName');
|
$client->setIdentifier('clientName');
|
||||||
@ -180,8 +181,8 @@ class BearerResponseTypeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$json = json_decode((string) $response->getBody());
|
$json = json_decode((string) $response->getBody());
|
||||||
|
|
||||||
$authorizationValidator = new BearerTokenValidator($accessTokenRepositoryMock);
|
$authorizationValidator = new BearerTokenValidator($accessTokenRepositoryMock);
|
||||||
$authorizationValidator->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$authorizationValidator->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
$authorizationValidator->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$authorizationValidator->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
|
|
||||||
$request = new ServerRequest();
|
$request = new ServerRequest();
|
||||||
$request = $request->withHeader('authorization', sprintf('Bearer %s', $json->access_token));
|
$request = $request->withHeader('authorization', sprintf('Bearer %s', $json->access_token));
|
||||||
@ -201,12 +202,12 @@ class BearerResponseTypeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
||||||
|
|
||||||
$responseType = new BearerTokenResponse($accessTokenRepositoryMock);
|
$responseType = new BearerTokenResponse($accessTokenRepositoryMock);
|
||||||
$responseType->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$responseType->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
$responseType->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$responseType->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
|
|
||||||
$authorizationValidator = new BearerTokenValidator($accessTokenRepositoryMock);
|
$authorizationValidator = new BearerTokenValidator($accessTokenRepositoryMock);
|
||||||
$authorizationValidator->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$authorizationValidator->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
$authorizationValidator->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$authorizationValidator->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
|
|
||||||
$request = new ServerRequest();
|
$request = new ServerRequest();
|
||||||
$request = $request->withHeader('authorization', 'Bearer blah');
|
$request = $request->withHeader('authorization', 'Bearer blah');
|
||||||
|
@ -28,8 +28,8 @@ class ServerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->getMock(ClientRepositoryInterface::class),
|
$this->getMock(ClientRepositoryInterface::class),
|
||||||
$this->getMock(AccessTokenRepositoryInterface::class),
|
$this->getMock(AccessTokenRepositoryInterface::class),
|
||||||
$this->getMock(ScopeRepositoryInterface::class),
|
$this->getMock(ScopeRepositoryInterface::class),
|
||||||
'',
|
'file://' . __DIR__ . '/Stubs/private.key',
|
||||||
'',
|
'file://' . __DIR__ . '/Stubs/public.key',
|
||||||
new StubResponseType()
|
new StubResponseType()
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -55,8 +55,8 @@ class ServerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientRepository,
|
$clientRepository,
|
||||||
$this->getMock(AccessTokenRepositoryInterface::class),
|
$this->getMock(AccessTokenRepositoryInterface::class),
|
||||||
$scopeRepositoryMock,
|
$scopeRepositoryMock,
|
||||||
'',
|
'file://' . __DIR__ . '/Stubs/private.key',
|
||||||
'',
|
'file://' . __DIR__ . '/Stubs/public.key',
|
||||||
new StubResponseType()
|
new StubResponseType()
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -125,8 +125,8 @@ class ServerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientRepository,
|
$clientRepository,
|
||||||
$this->getMock(AccessTokenRepositoryInterface::class),
|
$this->getMock(AccessTokenRepositoryInterface::class),
|
||||||
$this->getMock(ScopeRepositoryInterface::class),
|
$this->getMock(ScopeRepositoryInterface::class),
|
||||||
'',
|
'file://' . __DIR__ . '/Stubs/private.key',
|
||||||
''
|
'file://' . __DIR__ . '/Stubs/public.key'
|
||||||
);
|
);
|
||||||
|
|
||||||
$abstractGrantReflection = new \ReflectionClass($server);
|
$abstractGrantReflection = new \ReflectionClass($server);
|
||||||
@ -144,8 +144,8 @@ class ServerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientRepository,
|
$clientRepository,
|
||||||
$this->getMock(AccessTokenRepositoryInterface::class),
|
$this->getMock(AccessTokenRepositoryInterface::class),
|
||||||
$this->getMock(ScopeRepositoryInterface::class),
|
$this->getMock(ScopeRepositoryInterface::class),
|
||||||
'',
|
'file://' . __DIR__ . '/Stubs/private.key',
|
||||||
''
|
'file://' . __DIR__ . '/Stubs/public.key'
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace LeagueTests\Stubs;
|
namespace LeagueTests\Stubs;
|
||||||
|
|
||||||
|
use League\OAuth2\Server\CryptKey;
|
||||||
use League\OAuth2\Server\CryptTrait;
|
use League\OAuth2\Server\CryptTrait;
|
||||||
|
|
||||||
class CryptTraitStub
|
class CryptTraitStub
|
||||||
@ -10,8 +11,8 @@ class CryptTraitStub
|
|||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->setPrivateKeyPath('file://' . __DIR__ . '/private.key');
|
$this->setPrivateKey(new CryptKey('file://' . __DIR__ . '/private.key'));
|
||||||
$this->setPublicKeyPath('file://' . __DIR__ . '/public.key');
|
$this->setPublicKey(new CryptKey('file://' . __DIR__ . '/public.key'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function doEncrypt($unencryptedData)
|
public function doEncrypt($unencryptedData)
|
||||||
|
Loading…
Reference in New Issue
Block a user