diff --git a/src/ResourceServer.php b/src/ResourceServer.php index ab9ebec4..245cb4e2 100644 --- a/src/ResourceServer.php +++ b/src/ResourceServer.php @@ -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); diff --git a/src/TokenType/MAC.php b/src/TokenType/MAC.php index 0d026a2d..699c13b7 100644 --- a/src/TokenType/MAC.php +++ b/src/TokenType/MAC.php @@ -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(), ]; diff --git a/tests/unit/TokenType/MacTest.php b/tests/unit/TokenType/MacTest.php index c05ccdb4..d699e1b7 100644 --- a/tests/unit/TokenType/MacTest.php +++ b/tests/unit/TokenType/MacTest.php @@ -52,7 +52,7 @@ class MacTest extends \PHPUnit_Framework_TestCase $ts, 'foo', strtoupper($request->getMethod()), - $request->getUri(), + $request->getRequestUri(), $request->getHost(), $request->getPort(), 'ext'