mirror of
https://github.com/elyby/accounts.git
synced 2024-12-27 15:40:21 +05:30
Remove expires_in field when the access_token isn't expiring
This commit is contained in:
parent
22d8971dc5
commit
40eca5b8b6
@ -176,11 +176,15 @@ class OauthProcess {
|
||||
}
|
||||
|
||||
if (($result['expires_in'] ?? 0) <= 0) {
|
||||
// Since some of our clients use this field to understand how long the token will live,
|
||||
// we have to give it some value. The tokens with zero lifetime don't expire
|
||||
// but in order not to break the clients storing the value as integer on 32-bit systems,
|
||||
// let's calculate the value based on the unsigned maximum for this type
|
||||
$result['expires_in'] = 2 ** 31 - time();
|
||||
if ($shouldIssueRefreshToken || $grantType === 'refresh_token') {
|
||||
// Since some of our clients use this field to understand how long the token will live,
|
||||
// we have to give it some value. The tokens with zero lifetime don't expire
|
||||
// but in order not to break the clients storing the value as integer on 32-bit systems,
|
||||
// let's calculate the value based on the unsigned maximum for this type
|
||||
$result['expires_in'] = 2 ** 31 - time();
|
||||
} else {
|
||||
unset($result['expires_in']);
|
||||
}
|
||||
}
|
||||
|
||||
Yii::$app->statsd->inc("oauth.issueToken_client.{$clientId}");
|
||||
|
@ -22,7 +22,7 @@ class AccessTokenCest {
|
||||
'token_type' => 'Bearer',
|
||||
]);
|
||||
$I->canSeeResponseJsonMatchesJsonPath('$.access_token');
|
||||
$I->canSeeResponseJsonMatchesJsonPath('$.expires_in');
|
||||
$I->cantSeeResponseJsonMatchesJsonPath('$.expires_in');
|
||||
$I->cantSeeResponseJsonMatchesJsonPath('$.refresh_token');
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ class ClientCredentialsCest {
|
||||
'token_type' => 'Bearer',
|
||||
]);
|
||||
$I->canSeeResponseJsonMatchesJsonPath('$.access_token');
|
||||
$I->canSeeResponseJsonMatchesJsonPath('$.expires_in');
|
||||
$I->cantSeeResponseJsonMatchesJsonPath('$.expires_in');
|
||||
$I->cantSeeResponseJsonMatchesJsonPath('$.refresh_token');
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user