Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing token update when another field (e.g. last checked) changed #29681

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/private/Authentication/Token/DefaultTokenProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ public function updateTokenActivity(IToken $token) {
// Update token only once per minute
$token->setLastActivity($now);
$this->mapper->update($token);
} else if (!empty($token->getUpdatedFields())) {
$this->mapper->update($token);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while this fixes the issue it's weird that we do this regular update in a updateTokenActivity method, isn't it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only alternate approach is to either bring the double update back, or to move the acivity time calculation to the session and make the "which update to use" decision there:

$this->tokenProvider->updateTokenActivity($dbToken);
return true;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the double update is the subjectively cleanest as changes are written right where they are made

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also fine by me

}
}

Expand Down
9 changes: 8 additions & 1 deletion lib/private/Authentication/Token/PublicKeyTokenProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,15 @@ public function updateTokenActivity(IToken $token) {
/** @var PublicKeyToken $token */
$now = $this->time->getTime();
if ($token->getLastActivity() < ($now - $activityInterval)) {
$updateFull = !empty($token->getUpdatedFields());
CarlSchwan marked this conversation as resolved.
Show resolved Hide resolved
$token->setLastActivity($now);
$this->mapper->updateActivity($token, $now);
if ($updateFull) {
$this->mapper->update($token);
} else {
$this->mapper->updateActivity($token, $now);
}
} else if (!empty($token->getUpdatedFields())) {
$this->mapper->update($token);
}
}

Expand Down