mirror of
https://github.com/elyby/oauth2-server.git
synced 2025-01-31 15:59:31 +05:30
Merge pull request #101 from jackshakes/develop
Update Implicit Grant token TTL and response structure
This commit is contained in:
commit
556e9cc9ab
@ -42,6 +42,12 @@ class Implicit implements GrantTypeInterface {
|
|||||||
*/
|
*/
|
||||||
protected $authServer = null;
|
protected $authServer = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Access token expires in override
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $accessTokenTTL = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param Authorization $authServer Authorization server instance
|
* @param Authorization $authServer Authorization server instance
|
||||||
@ -70,6 +76,16 @@ class Implicit implements GrantTypeInterface {
|
|||||||
return $this->responseType;
|
return $this->responseType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override the default access token expire time
|
||||||
|
* @param int $accessTokenTTL
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setAccessTokenTTL($accessTokenTTL)
|
||||||
|
{
|
||||||
|
$this->accessTokenTTL = $accessTokenTTL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Complete the client credentials grant
|
* Complete the client credentials grant
|
||||||
* @param null|array $inputParams
|
* @param null|array $inputParams
|
||||||
@ -84,7 +100,8 @@ class Implicit implements GrantTypeInterface {
|
|||||||
$accessToken = SecureKey::make();
|
$accessToken = SecureKey::make();
|
||||||
|
|
||||||
// Compute expiry time
|
// Compute expiry time
|
||||||
$accessTokenExpires = time() + $this->authServer->getAccessTokenTTL();
|
$accessTokenExpiresIn = ($this->accessTokenTTL !== null) ? $this->accessTokenTTL : $this->authServer->getAccessTokenTTL();
|
||||||
|
$accessTokenExpires = time() + $accessTokenExpiresIn;
|
||||||
|
|
||||||
// Create a new session
|
// Create a new session
|
||||||
$sessionId = $this->authServer->getStorage('session')->createSession($authParams['client_id'], 'user', $authParams['user_id']);
|
$sessionId = $this->authServer->getStorage('session')->createSession($authParams['client_id'], 'user', $authParams['user_id']);
|
||||||
@ -98,7 +115,10 @@ class Implicit implements GrantTypeInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$response = array(
|
$response = array(
|
||||||
'access_token' => $accessToken
|
'access_token' => $accessToken,
|
||||||
|
'token_type' => 'Bearer',
|
||||||
|
'expires' => $accessTokenExpires,
|
||||||
|
'expires_in' => $accessTokenExpiresIn,
|
||||||
);
|
);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user