No longer need to inject auth server into grant

This commit is contained in:
Alex Bilbie 2013-12-05 20:25:50 +00:00
parent b55b73c1e8
commit 262ce23fb9
8 changed files with 34 additions and 52 deletions

View File

@ -244,6 +244,10 @@ class Authorization
if (is_null($identifier)) {
$identifier = $grantType->getIdentifier();
}
// Inject server into grant
$grantType->setAuthorizationServer($this);
$this->grantTypes[$identifier] = $grantType;
if ( ! is_null($grantType->getResponseType())) {

View File

@ -56,16 +56,6 @@ class AuthCode implements GrantTypeInterface {
*/
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
* @param int $authTokenTTL

View File

@ -50,16 +50,6 @@ class ClientCredentials implements GrantTypeInterface {
*/
protected $accessTokenTTL = null;
/**
* Constructor
* @param Authorization $authServer Authorization server instance
* @return void
*/
public function __construct(Authorization $authServer)
{
$this->authServer = $authServer;
}
/**
* Return the identifier
* @return string

View File

@ -11,8 +11,26 @@
namespace League\OAuth2\Server\Grant;
use League\OAuth2\Server\Authorization;
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 string
@ -42,4 +60,15 @@ trait GrantTrait {
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;
}
}

View File

@ -23,10 +23,9 @@ interface GrantTypeInterface
{
/**
* Constructor
* @param Authorization $authServer Authorization server instance
* @return void
*/
public function __construct(Authorization $authServer);
public function __construct(Authorization $authServer = null);
/**
* Complete the grant flow

View File

@ -50,16 +50,6 @@ class Implicit implements GrantTypeInterface {
*/
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
* @param null|array $inputParams

View File

@ -56,16 +56,6 @@ class Password implements GrantTypeInterface {
*/
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
* @param callable $callback The callback function

View File

@ -62,16 +62,6 @@ class RefreshToken implements GrantTypeInterface {
*/
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
* @param int $refreshTokenTTL