mirror of
https://github.com/elyby/accounts.git
synced 2024-11-06 08:11:24 +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) {
|
if (($result['expires_in'] ?? 0) <= 0) {
|
||||||
|
if ($shouldIssueRefreshToken || $grantType === 'refresh_token') {
|
||||||
// Since some of our clients use this field to understand how long the token will live,
|
// 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
|
// 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,
|
// 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
|
// let's calculate the value based on the unsigned maximum for this type
|
||||||
$result['expires_in'] = 2 ** 31 - time();
|
$result['expires_in'] = 2 ** 31 - time();
|
||||||
|
} else {
|
||||||
|
unset($result['expires_in']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Yii::$app->statsd->inc("oauth.issueToken_client.{$clientId}");
|
Yii::$app->statsd->inc("oauth.issueToken_client.{$clientId}");
|
||||||
|
@ -22,7 +22,7 @@ class AccessTokenCest {
|
|||||||
'token_type' => 'Bearer',
|
'token_type' => 'Bearer',
|
||||||
]);
|
]);
|
||||||
$I->canSeeResponseJsonMatchesJsonPath('$.access_token');
|
$I->canSeeResponseJsonMatchesJsonPath('$.access_token');
|
||||||
$I->canSeeResponseJsonMatchesJsonPath('$.expires_in');
|
$I->cantSeeResponseJsonMatchesJsonPath('$.expires_in');
|
||||||
$I->cantSeeResponseJsonMatchesJsonPath('$.refresh_token');
|
$I->cantSeeResponseJsonMatchesJsonPath('$.refresh_token');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ class ClientCredentialsCest {
|
|||||||
'token_type' => 'Bearer',
|
'token_type' => 'Bearer',
|
||||||
]);
|
]);
|
||||||
$I->canSeeResponseJsonMatchesJsonPath('$.access_token');
|
$I->canSeeResponseJsonMatchesJsonPath('$.access_token');
|
||||||
$I->canSeeResponseJsonMatchesJsonPath('$.expires_in');
|
$I->cantSeeResponseJsonMatchesJsonPath('$.expires_in');
|
||||||
$I->cantSeeResponseJsonMatchesJsonPath('$.refresh_token');
|
$I->cantSeeResponseJsonMatchesJsonPath('$.refresh_token');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user