feat: enable bridges using env var (#3428)

* refactor: bridgefactory, add tests

* refactor: move defaultly enabled bridges to config

* refactor

* refactor

* feat: add support for enabling bridges with env var
This commit is contained in:
Dag 2023-06-11 03:16:03 +02:00 committed by GitHub
parent d9490c6518
commit 0a8fe57003
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 179 additions and 182 deletions

View file

@ -23,17 +23,10 @@ class SetBridgeCacheAction implements ActionInterface
$bridgeFactory = new BridgeFactory();
$bridgeClassName = null;
if (isset($request['bridge'])) {
$bridgeClassName = $bridgeFactory->sanitizeBridgeName($request['bridge']);
}
if ($bridgeClassName === null) {
throw new \InvalidArgumentException('Bridge name invalid!');
}
$bridgeClassName = $bridgeFactory->createBridgeClassName($request['bridge'] ?? '');
// whitelist control
if (!$bridgeFactory->isWhitelisted($bridgeClassName)) {
if (!$bridgeFactory->isEnabled($bridgeClassName)) {
throw new \Exception('This bridge is not whitelisted', 401);
die;
}