-
Notifications
You must be signed in to change notification settings - Fork 118
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
feat: Check remove server connectivity #4361
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -9,6 +9,8 @@ | |||||
use Exception; | ||||||
use OCA\Richdocuments\AppConfig; | ||||||
use OCA\Richdocuments\WOPI\Parser; | ||||||
use OCP\Http\Client\IClientService; | ||||||
use OCP\IURLGenerator; | ||||||
use Symfony\Component\Console\Output\OutputInterface; | ||||||
|
||||||
class ConnectivityService { | ||||||
|
@@ -17,6 +19,8 @@ | |||||
private DiscoveryService $discoveryService, | ||||||
private CapabilitiesService $capabilitiesService, | ||||||
private Parser $parser, | ||||||
private IClientService $clientService, | ||||||
private IURLGenerator $urlGenerator, | ||||||
) { | ||||||
} | ||||||
|
||||||
|
@@ -47,6 +51,38 @@ | |||||
$output->writeln('<info>✓ Detected WOPI server: ' . $this->capabilitiesService->getServerProductName() . ' ' . $this->capabilitiesService->getProductVersion() . '</info>'); | ||||||
} | ||||||
|
||||||
public function testCallback(OutputInterface $output): void { | ||||||
Check failure on line 54 in lib/Service/ConnectivityService.php GitHub Actions / static-psalm-analysisUndefinedClass
|
||||||
$url = $this->parser->getUrlSrcValue('Capabilities'); | ||||||
if ($url === '') { | ||||||
// Fixme can we skip early if the collabora version does not have the wopiAccessCheck endpoint, maybe it can be exposed in discovery | ||||||
return; | ||||||
} | ||||||
|
||||||
$url = str_replace('/hosting/capabilities', '/hosting/wopiAccessCheck', $url); | ||||||
|
||||||
$callbackUrl = $this->urlGenerator->getAbsoluteURL('/status.php'); | ||||||
|
||||||
$client = $this->clientService->newClient(); | ||||||
try { | ||||||
$response = $client->post($url, [ | ||||||
...RemoteOptionsService::getDefaultOptions(), | ||||||
'body' => json_encode([ | ||||||
'callbackUrl' => $callbackUrl, | ||||||
]), | ||||||
'headers' => [ | ||||||
'Content-Type' => 'application/json', | ||||||
], | ||||||
]); | ||||||
$result = json_decode($response->getBody(), true, 512, JSON_THROW_ON_ERROR); | ||||||
if ($result['status'] === 'CheckStatus::WopiHostNotAllowed') { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I have simplified this to just be I am taking the time window until mid-january and next COOL stable version to make small API corrections before they are completely set in stone. |
||||||
throw new \Exception('WOPI host not allowed by Collabora'); | ||||||
} | ||||||
} catch (Exception $e) { | ||||||
throw $e; | ||||||
} | ||||||
$output->writeln('<info>✓ URL Callback ok</info>'); | ||||||
} | ||||||
|
||||||
/** | ||||||
* Detect public URL of the WOPI server for setting CSP on Nextcloud | ||||||
* | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was suggested will probably add to discovery.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be available with CollaboraOnline/online#10840 with
hasWopiAccessCheck
key in the /hosting/capabilities json answer.