Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions lib/Command/CirclesCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
use OCA\Circles\Tools\Traits\TArrayTools;
use OCA\Circles\Tools\Traits\TNCRequest;
use OCA\Circles\Tools\Traits\TStringTools;
use OCP\IConfig;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -107,6 +108,8 @@ class CirclesCheck extends Base {
/** @var ConfigService */
private $configService;

/** @var IConfig */
private $config;

/** @var array */
private $sessions = [];
Expand All @@ -125,6 +128,7 @@ class CirclesCheck extends Base {
*/
public function __construct(
Capabilities $capabilities,
IConfig $config,
InterfaceService $interfaceService,
FederatedEventService $federatedEventService,
RemoteService $remoteService,
Expand All @@ -135,6 +139,7 @@ public function __construct(
parent::__construct();

$this->capabilities = $capabilities;
$this->config = $config;
$this->interfaceService = $interfaceService;
$this->federatedEventService = $federatedEventService;
$this->remoteService = $remoteService;
Expand Down Expand Up @@ -333,6 +338,7 @@ private function testLoopback(InputInterface $input, OutputInterface $output): b
return false;
}

$this->config->setAppValue(Application::APP_ID, 'test_dummy_token', (string)(time() + 10));
if (!$this->testRequest(
$output, 'POST', 'circles.EventWrapper.asyncBroadcast',
['token' => 'test-dummy-token']
Expand Down
10 changes: 9 additions & 1 deletion lib/Controller/EventWrapperController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\IConfig;
use OCP\IRequest;

/**
Expand All @@ -68,7 +69,8 @@ class EventWrapperController extends Controller {

/** @var ConfigService */
private $configService;

/** @var IConfig */
private $config;

/**
* EventWrapperController constructor.
Expand All @@ -84,13 +86,15 @@ class EventWrapperController extends Controller {
public function __construct(
string $appName,
IRequest $request,
IConfig $config,
EventWrapperService $eventWrapperService,
FederatedEventService $federatedEventService,
RemoteUpstreamService $remoteUpstreamService,
RemoteDownstreamService $remoteDownstreamService,
ConfigService $configService
) {
parent::__construct($appName, $request);
$this->config = $config;
$this->eventWrapperService = $eventWrapperService;
$this->federatedEventService = $federatedEventService;
$this->remoteUpstreamService = $remoteUpstreamService;
Expand Down Expand Up @@ -121,6 +125,10 @@ public function asyncBroadcast(string $token): DataResponse {
return new DataResponse(null, Http::STATUS_OK);
}

if ($token === 'test-dummy-token' && ((int)$this->config->getAppValue(Application::APP_ID, 'test_dummy_token', '0')) < time()) {
return new DataResponse([], Http::STATUS_UNAUTHORIZED);
}

// closing socket, keep current process running.
$this->async();

Expand Down
Loading