mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-22 13:09:44 +05:30
TokenType -> ResponseType
This commit is contained in:
parent
0a602cb022
commit
1442842da9
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* OAuth 2.0 Abstract Token Type
|
||||
* OAuth 2.0 Abstract Response Type
|
||||
*
|
||||
* @package league/oauth2-server
|
||||
* @author Alex Bilbie <hello@alexbilbie.com>
|
||||
@ -9,15 +9,14 @@
|
||||
* @link https://github.com/thephpleague/oauth2-server
|
||||
*/
|
||||
|
||||
namespace League\OAuth2\Server\TokenTypes;
|
||||
namespace League\OAuth2\Server\ResponseTypes;
|
||||
|
||||
use League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
abstract class AbstractTokenType implements TokenTypeInterface
|
||||
abstract class AbstractResponseType implements ResponseTypeInterface
|
||||
{
|
||||
/**
|
||||
* Response array
|
||||
* Response array for JSON serialization
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
@ -51,20 +50,4 @@ abstract class AbstractTokenType implements TokenTypeInterface
|
||||
{
|
||||
$this->accessToken = $accessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function generateHttpResponse()
|
||||
{
|
||||
return new Response(
|
||||
json_encode($this->generateResponse()),
|
||||
200,
|
||||
[
|
||||
'Content-type' => 'application/json',
|
||||
'Cache-Control' => 'no-store',
|
||||
'Pragma' => 'no-cache'
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
@ -9,17 +9,17 @@
|
||||
* @link https://github.com/thephpleague/oauth2-server
|
||||
*/
|
||||
|
||||
namespace League\OAuth2\Server\TokenTypes;
|
||||
namespace League\OAuth2\Server\ResponseTypes;
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Zend\Diactoros\Response;
|
||||
|
||||
class BearerTokenType extends AbstractTokenType
|
||||
class BearerTokenResponse extends AbstractResponseType
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function generateResponse()
|
||||
public function generateHttpResponse()
|
||||
{
|
||||
$values = [
|
||||
'access_token' => $this->accessToken->getIdentifier(),
|
55
src/ResponseTypes/ResponseTypeInterface.php
Normal file
55
src/ResponseTypes/ResponseTypeInterface.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* OAuth 2.0 Response Type Interface
|
||||
*
|
||||
* @package league/oauth2-server
|
||||
* @author Alex Bilbie <hello@alexbilbie.com>
|
||||
* @copyright Copyright (c) Alex Bilbie
|
||||
* @license http://mit-license.org/
|
||||
* @link https://github.com/thephpleague/oauth2-server
|
||||
*/
|
||||
|
||||
namespace League\OAuth2\Server\ResponseTypes;
|
||||
|
||||
use League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
interface ResponseTypeInterface
|
||||
{
|
||||
/**
|
||||
* @param \League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface $accessToken
|
||||
*/
|
||||
public function setAccessToken(AccessTokenEntityInterface $accessToken);
|
||||
|
||||
/**
|
||||
* Set a key/value response pair
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setParam($key, $value);
|
||||
|
||||
/**
|
||||
* Get a key from the response array
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getParam($key);
|
||||
|
||||
/**
|
||||
* Determine the access token in the authorization header
|
||||
*
|
||||
* @param ServerRequestInterface $request
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function determineAccessTokenInHeader(ServerRequestInterface $request);
|
||||
|
||||
/**
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function generateHttpResponse();
|
||||
}
|
Loading…
Reference in New Issue
Block a user