diff --git a/.gitattributes b/.gitattributes index 3819f5cd..cae05a90 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,4 @@ tests/ export-ignore phpunit.xml export-ignore -build.xml export-ignore -test export-ignore -.travis.yml export-ignore \ No newline at end of file +.travis.yml export-ignore +.scrutinizer.yml export-ignore \ No newline at end of file diff --git a/.gitignore b/.gitignore index 941a7dcf..3d7227d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,3 @@ /vendor /composer.lock -/build -/docs -/testing -/examples/relational/vendor -/examples/relational/config/oauth2.sqlite3 -/examples/nosql/vendor -/examples/nosql/config/oauth2.sqlite3 -/examples/relational/composer.lock -/tests/codecept/tests/_log -oauth2-server.paw -/output_*/ -/_site .idea \ No newline at end of file diff --git a/src/TokenTypes/AbstractTokenType.php b/src/ResponseTypes/AbstractResponseType.php similarity index 100% rename from src/TokenTypes/AbstractTokenType.php rename to src/ResponseTypes/AbstractResponseType.php diff --git a/src/TokenTypes/Bearer.php b/src/ResponseTypes/BearerTokenResponseType.php similarity index 71% rename from src/TokenTypes/Bearer.php rename to src/ResponseTypes/BearerTokenResponseType.php index 47e1a908..a132b53a 100644 --- a/src/TokenTypes/Bearer.php +++ b/src/ResponseTypes/BearerTokenResponseType.php @@ -11,9 +11,10 @@ namespace League\OAuth2\Server\TokenTypes; +use Period\Period; use Symfony\Component\HttpFoundation\Request; -class Bearer extends AbstractTokenType +class BearerTokenType extends AbstractTokenType { /** * {@inheritdoc} @@ -21,9 +22,12 @@ class Bearer extends AbstractTokenType public function generateResponse() { $return = [ - 'access_token' => $this->getParam('access_token'), - 'token_type' => 'Bearer', - 'expires_in' => $this->getParam('expires_in'), + 'access_token' => $this->accessToken->getIdentifier(), + 'token_type' => 'Bearer', + 'expires_in' => (new Period( + new \DateTime(), + $this->accessToken->getExpiryDateTime()) + )->getTimestampInterval(), ]; if (!is_null($this->getParam('refresh_token'))) { @@ -41,6 +45,8 @@ class Bearer extends AbstractTokenType $header = $request->headers->get('Authorization'); $accessToken = trim(preg_replace('/^(?:\s+)?Bearer\s/', '', $header)); + // ^(?:\s+)?Bearer\s([a-zA-Z0-9-._~+/=]*) + return ($accessToken === 'Bearer') ? '' : $accessToken; } } diff --git a/src/TokenTypes/MAC.php b/src/ResponseTypes/MAC.php similarity index 100% rename from src/TokenTypes/MAC.php rename to src/ResponseTypes/MAC.php diff --git a/src/TokenTypes/TokenTypeInterface.php b/src/ResponseTypes/ResponseTypeInterface.php similarity index 100% rename from src/TokenTypes/TokenTypeInterface.php rename to src/ResponseTypes/ResponseTypeInterface.php