mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-64079 oauth2: Set an arbitrary expiration date for eternal tokens
The oauth2 standard does not require access tokens to have an expiration date. This assumes a default validity period of 7 days unless an explicit expiration date is communicated by the server.
This commit is contained in:
parent
0225ad42ea
commit
121fa4381e
@ -175,7 +175,13 @@ class client extends \oauth2_client {
|
||||
}
|
||||
// Update values from $token. Don't use from_record because that would skip validation.
|
||||
$persistedtoken->set('token', $token->token);
|
||||
$persistedtoken->set('expires', $token->expires);
|
||||
if (isset($token->expires)) {
|
||||
$persistedtoken->set('expires', $token->expires);
|
||||
} else {
|
||||
// Assume an arbitrary time span of 1 week for access tokens without expiration.
|
||||
// The "refresh_system_tokens_task" is run hourly (by default), so the token probably won't last that long.
|
||||
$persistedtoken->set('expires', time() + WEEKSECS);
|
||||
}
|
||||
$persistedtoken->set('scope', $token->scope);
|
||||
$persistedtoken->save();
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user