discoveryService = Server::get(OCMDiscoveryService::class); $this->trustedServers = Server::get(TrustedServers::class); } #[\Override] public function shouldApply(IRequest $request): bool { if ($this->trustedServers === null) { return true; } try { $owner = $request->getParam('owner'); $signedRequest = $this->discoveryService->getIncomingSignedRequest(is_string($owner) ? $owner : null); if (!$signedRequest) { return true; } return !$this->trustedServers->isTrustedServer($signedRequest->getOrigin()); } catch (\Exception) { // no or invalid signature, or unresolvable origin return true; } } }