mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-01 16:33:07 +05:30
No longer need to inject auth server into grant
This commit is contained in:
parent
b55b73c1e8
commit
262ce23fb9
@ -244,6 +244,10 @@ class Authorization
|
|||||||
if (is_null($identifier)) {
|
if (is_null($identifier)) {
|
||||||
$identifier = $grantType->getIdentifier();
|
$identifier = $grantType->getIdentifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inject server into grant
|
||||||
|
$grantType->setAuthorizationServer($this);
|
||||||
|
|
||||||
$this->grantTypes[$identifier] = $grantType;
|
$this->grantTypes[$identifier] = $grantType;
|
||||||
|
|
||||||
if ( ! is_null($grantType->getResponseType())) {
|
if ( ! is_null($grantType->getResponseType())) {
|
||||||
|
@ -56,16 +56,6 @@ class AuthCode implements GrantTypeInterface {
|
|||||||
*/
|
*/
|
||||||
protected $authTokenTTL = 600;
|
protected $authTokenTTL = 600;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
* @param Authorization $authServer Authorization server instance
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct(Authorization $authServer)
|
|
||||||
{
|
|
||||||
$this->authServer = $authServer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override the default access token expire time
|
* Override the default access token expire time
|
||||||
* @param int $authTokenTTL
|
* @param int $authTokenTTL
|
||||||
|
@ -50,16 +50,6 @@ class ClientCredentials implements GrantTypeInterface {
|
|||||||
*/
|
*/
|
||||||
protected $accessTokenTTL = null;
|
protected $accessTokenTTL = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
* @param Authorization $authServer Authorization server instance
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct(Authorization $authServer)
|
|
||||||
{
|
|
||||||
$this->authServer = $authServer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the identifier
|
* Return the identifier
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -11,8 +11,26 @@
|
|||||||
|
|
||||||
namespace League\OAuth2\Server\Grant;
|
namespace League\OAuth2\Server\Grant;
|
||||||
|
|
||||||
|
use League\OAuth2\Server\Authorization;
|
||||||
|
|
||||||
trait GrantTrait {
|
trait GrantTrait {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param Authorization $authServer Authorization server instance
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(Authorization $authServer = null)
|
||||||
|
{
|
||||||
|
// @codeCoverageIgnoreStart
|
||||||
|
if ($authServer instanceof Authorization) {
|
||||||
|
trigger_error(
|
||||||
|
'Server is now automatically injected into grant as of v3.1 of this library',
|
||||||
|
E_USER_DEPRECATED
|
||||||
|
);
|
||||||
|
} // @codeCoverageIgnoreEnd
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the identifier
|
* Return the identifier
|
||||||
* @return string
|
* @return string
|
||||||
@ -42,4 +60,15 @@ trait GrantTrait {
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inject the authorization server into the grant
|
||||||
|
* @param Authorization $authServer The authorization server instance
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setAuthorizationServer(Authorization $authServer)
|
||||||
|
{
|
||||||
|
$this->authServer = $authServer;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -23,10 +23,9 @@ interface GrantTypeInterface
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param Authorization $authServer Authorization server instance
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(Authorization $authServer);
|
public function __construct(Authorization $authServer = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Complete the grant flow
|
* Complete the grant flow
|
||||||
|
@ -50,16 +50,6 @@ class Implicit implements GrantTypeInterface {
|
|||||||
*/
|
*/
|
||||||
protected $accessTokenTTL = null;
|
protected $accessTokenTTL = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
* @param Authorization $authServer Authorization server instance
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct(Authorization $authServer)
|
|
||||||
{
|
|
||||||
$this->authServer = $authServer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Complete the client credentials grant
|
* Complete the client credentials grant
|
||||||
* @param null|array $inputParams
|
* @param null|array $inputParams
|
||||||
|
@ -56,16 +56,6 @@ class Password implements GrantTypeInterface {
|
|||||||
*/
|
*/
|
||||||
protected $accessTokenTTL = null;
|
protected $accessTokenTTL = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
* @param Authorization $authServer Authorization server instance
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct(Authorization $authServer)
|
|
||||||
{
|
|
||||||
$this->authServer = $authServer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the callback to verify a user's username and password
|
* Set the callback to verify a user's username and password
|
||||||
* @param callable $callback The callback function
|
* @param callable $callback The callback function
|
||||||
|
@ -62,16 +62,6 @@ class RefreshToken implements GrantTypeInterface {
|
|||||||
*/
|
*/
|
||||||
protected $rotateRefreshTokens = false;
|
protected $rotateRefreshTokens = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
* @param Authorization $authServer Authorization server instance
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct(Authorization $authServer)
|
|
||||||
{
|
|
||||||
$this->authServer = $authServer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the TTL of the refresh token
|
* Set the TTL of the refresh token
|
||||||
* @param int $refreshTokenTTL
|
* @param int $refreshTokenTTL
|
||||||
|
Loading…
Reference in New Issue
Block a user