Merge remote-tracking branch 'thephpleague/master' into fix-bug-hmac-encoding

This commit is contained in:
Michael Hogg 2015-09-02 09:50:46 +01:00
commit d21374fb0b
3 changed files with 9 additions and 4 deletions

View File

@ -19,6 +19,7 @@ use League\OAuth2\Server\Storage\ClientInterface;
use League\OAuth2\Server\Storage\ScopeInterface;
use League\OAuth2\Server\Storage\SessionInterface;
use League\OAuth2\Server\TokenType\Bearer;
use League\OAuth2\Server\TokenType\MAC;
/**
* OAuth 2.0 Resource Server
@ -139,7 +140,7 @@ class ResourceServer extends AbstractServer
{
if ($this->getRequest()->headers->get('Authorization') !== null) {
$accessToken = $this->getTokenType()->determineAccessTokenInHeader($this->getRequest());
} elseif ($headerOnly === false) {
} elseif ($headerOnly === false && (! $this->getTokenType() instanceof MAC)) {
$accessToken = ($this->getRequest()->server->get('REQUEST_METHOD') === 'GET')
? $this->getRequest()->query->get($this->tokenKey)
: $this->getRequest()->request->get($this->tokenKey);

View File

@ -36,6 +36,10 @@ class MAC extends AbstractTokenType implements TokenTypeInterface
'mac_algorithm' => 'hmac-sha-256',
];
if (!is_null($this->getParam('refresh_token'))) {
$response['refresh_token'] = $this->getParam('refresh_token');
}
return $response;
}
@ -61,7 +65,7 @@ class MAC extends AbstractTokenType implements TokenTypeInterface
array_map(function ($param) use (&$params) {
$param = trim($param);
preg_match_all('/([a-zA-Z]*)="([\w=]*)"/', $param, $matches);
preg_match_all('/([a-zA-Z]*)="([\w=\/+]*)"/', $param, $matches);
// @codeCoverageIgnoreStart
if (count($matches) !== 3) {
@ -105,7 +109,7 @@ class MAC extends AbstractTokenType implements TokenTypeInterface
$timestamp,
$nonce,
strtoupper($request->getMethod()),
$request->getUri(),
$request->getRequestUri(),
$request->getHost(),
$request->getPort(),
];

View File

@ -52,7 +52,7 @@ class MacTest extends \PHPUnit_Framework_TestCase
$ts,
'foo',
strtoupper($request->getMethod()),
$request->getUri(),
$request->getRequestUri(),
$request->getHost(),
$request->getPort(),
'ext'