mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-23 05:29:52 +05:30
Small fixes
This commit is contained in:
parent
85b9412813
commit
d95958bae4
@ -74,6 +74,7 @@ class AuthCodeGrant extends AbstractGrant
|
|||||||
$this->pathToAuthorizeTemplate = ($pathToLoginTemplate === null)
|
$this->pathToAuthorizeTemplate = ($pathToLoginTemplate === null)
|
||||||
? __DIR__ . '/../ResponseTypes/DefaultTemplates/authorize_client.php'
|
? __DIR__ . '/../ResponseTypes/DefaultTemplates/authorize_client.php'
|
||||||
: $this->pathToAuthorizeTemplate;
|
: $this->pathToAuthorizeTemplate;
|
||||||
|
$this->refreshTokenTTL = new \DateInterval('P1M');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -234,7 +235,7 @@ class AuthCodeGrant extends AbstractGrant
|
|||||||
'auth_code_id' => $authCode->getIdentifier(),
|
'auth_code_id' => $authCode->getIdentifier(),
|
||||||
'scopes' => $authCode->getScopes(),
|
'scopes' => $authCode->getScopes(),
|
||||||
'user_id' => $authCode->getUserIdentifier(),
|
'user_id' => $authCode->getUserIdentifier(),
|
||||||
'expire_time' => $this->authCodeTTL->format('U'),
|
'expire_time' => (new \DateTime())->add($this->authCodeTTL)->format('U'),
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
$this->pathToPrivateKey
|
$this->pathToPrivateKey
|
||||||
@ -272,7 +273,7 @@ class AuthCodeGrant extends AbstractGrant
|
|||||||
|
|
||||||
// Validate the authorization code
|
// Validate the authorization code
|
||||||
try {
|
try {
|
||||||
$authCodePayload = json_decode(KeyCrypt::decrypt($encryptedAuthCode, $this->pathToPrivateKey));
|
$authCodePayload = json_decode(KeyCrypt::decrypt($encryptedAuthCode, $this->pathToPublicKey));
|
||||||
if (time() > $authCodePayload->expire_time) {
|
if (time() > $authCodePayload->expire_time) {
|
||||||
throw OAuthServerException::invalidRequest('code', 'Authorization code has expired');
|
throw OAuthServerException::invalidRequest('code', 'Authorization code has expired');
|
||||||
}
|
}
|
||||||
@ -285,7 +286,7 @@ class AuthCodeGrant extends AbstractGrant
|
|||||||
throw OAuthServerException::invalidRequest('code', 'Authorization code was not issued to this client');
|
throw OAuthServerException::invalidRequest('code', 'Authorization code was not issued to this client');
|
||||||
}
|
}
|
||||||
} catch (\LogicException $e) {
|
} catch (\LogicException $e) {
|
||||||
throw OAuthServerException::invalidRequest('code');
|
throw OAuthServerException::invalidRequest('code', null, 'Cannot decrypt the authorization code');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Issue and persist access + refresh tokens
|
// Issue and persist access + refresh tokens
|
||||||
|
Loading…
Reference in New Issue
Block a user