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(federation): re-add RequestSharedSecret job if necessary #44848

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions apps/federation/lib/Controller/OCSAuthAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
*/
namespace OCA\Federation\Controller;

use OCA\Federation\BackgroundJob\RequestSharedSecret;
use OCA\Federation\DbHandler;
use OCA\Federation\TrustedServers;
use OCP\AppFramework\Http;
Expand Down Expand Up @@ -147,6 +148,21 @@ public function requestSharedSecret(string $url, string $token): DataResponse {
'remote server (' . $url . ') presented lower token. We will initiate the exchange of the shared secret.',
['app' => 'federation']
);

$hasJob = false;
foreach ($this->jobList->getJobsIterator(RequestSharedSecret::class, 1, 0) as $job) {
$hasJob = true;
Copy link
Member

Choose a reason for hiding this comment

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

but this could be for another URL?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, good point. Shall compare that argument then.

Copy link
Member

Choose a reason for hiding this comment

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

And then either loop over all or get chunks until you found 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.

Yes. I would have looked for the hasJob, but the timestamp ruins it.

}
if (!$hasJob) {
$this->jobList->add(
RequestSharedSecret::class,
[
'url' => $url,
'token' => $this->dbHandler->getToken($url),
'created' => $this->timeFactory->getTime()
]
);
}
throw new OCSForbiddenException();
}

Expand Down