Skip to content
Snippets Groups Projects
Commit 6451917b authored by Tobias Gross-Vogt's avatar Tobias Gross-Vogt
Browse files

proxyapi update; rename keycloak -> oidc

parent 27e4adc9
Branches
Tags
No related merge requests found
...@@ -13,8 +13,8 @@ class ApiConnection ...@@ -13,8 +13,8 @@ class ApiConnection
{ {
public const API_URL_CONFIG_PARAMETER = 'api_url'; public const API_URL_CONFIG_PARAMETER = 'api_url';
public const KEYCLOAK_SERVER_URL_CONFIG_PARAMETER = 'keycloak_server_url'; public const OIDC_SERVER_URL_CONFIG_PARAMETER = 'oidc_server_url';
public const KEYCLOAK_REALM_CONFIG_PARAMETER = 'keycloak_realm'; public const OIDC_REALM_CONFIG_PARAMETER = 'oidc_realm';
public const CLIENT_ID_CONFIG_PARAMETER = 'client_id'; public const CLIENT_ID_CONFIG_PARAMETER = 'client_id';
public const CLIENT_SECRET_CONFIG_PARAMETER = 'client_secret'; public const CLIENT_SECRET_CONFIG_PARAMETER = 'client_secret';
...@@ -111,8 +111,8 @@ class ApiConnection ...@@ -111,8 +111,8 @@ class ApiConnection
private function getAccessToken(): string private function getAccessToken(): string
{ {
if ($this->accessToken === null) { if ($this->accessToken === null) {
$idServerUrl = $this->config[self::KEYCLOAK_SERVER_URL_CONFIG_PARAMETER]; $idServerUrl = $this->config[self::OIDC_SERVER_URL_CONFIG_PARAMETER];
$idServerRealm = $this->config[self::KEYCLOAK_REALM_CONFIG_PARAMETER]; $idServerRealm = $this->config[self::OIDC_REALM_CONFIG_PARAMETER];
$clientId = $this->config[self::CLIENT_ID_CONFIG_PARAMETER]; $clientId = $this->config[self::CLIENT_ID_CONFIG_PARAMETER];
$clientSecret = $this->config[self::CLIENT_SECRET_CONFIG_PARAMETER]; $clientSecret = $this->config[self::CLIENT_SECRET_CONFIG_PARAMETER];
......
...@@ -15,7 +15,7 @@ abstract class AbstractProxyDataEventSubscriber implements EventSubscriberInterf ...@@ -15,7 +15,7 @@ abstract class AbstractProxyDataEventSubscriber implements EventSubscriberInterf
public static function getSubscribedEvents(): array public static function getSubscribedEvents(): array
{ {
return [ return [
ProxyApi::PROXY_DATA_EVENT_NAME.static::NAMESPACE => 'onProxyDataEvent', ProxyDataEvent::NAME.'.'.static::NAMESPACE => 'onProxyDataEvent',
]; ];
} }
...@@ -24,7 +24,7 @@ abstract class AbstractProxyDataEventSubscriber implements EventSubscriberInterf ...@@ -24,7 +24,7 @@ abstract class AbstractProxyDataEventSubscriber implements EventSubscriberInterf
*/ */
public function onProxyDataEvent(ProxyDataEvent $event): void public function onProxyDataEvent(ProxyDataEvent $event): void
{ {
$event->setHandled(); $event->acknowledge();
$proxyData = $event->getProxyData(); $proxyData = $event->getProxyData();
$functionName = $proxyData->getFunctionName(); $functionName = $proxyData->getFunctionName();
$arguments = $proxyData->getArguments(); $arguments = $proxyData->getArguments();
......
...@@ -6,8 +6,6 @@ namespace Dbp\Relay\CoreBundle\ProxyApi; ...@@ -6,8 +6,6 @@ namespace Dbp\Relay\CoreBundle\ProxyApi;
class ProxyApi class ProxyApi
{ {
public const PROXY_DATA_EVENT_NAME = '';
public const PROXY_DATA_RETURN_VALUE_KEY = 'data'; public const PROXY_DATA_RETURN_VALUE_KEY = 'data';
public const PROXY_DATA_ERRORS_KEY = 'errors'; public const PROXY_DATA_ERRORS_KEY = 'errors';
} }
...@@ -8,18 +8,18 @@ use Symfony\Contracts\EventDispatcher\Event; ...@@ -8,18 +8,18 @@ use Symfony\Contracts\EventDispatcher\Event;
class ProxyDataEvent extends Event class ProxyDataEvent extends Event
{ {
public const NAME = 'dbp.relay.proxy_bundle.proxy_data'; public const NAME = 'dbp.relay.core_bundle.proxy_data';
/** @var ProxyDataInterface */ /** @var ProxyDataInterface */
private $proxyData; private $proxyData;
/** @var bool */ /** @var bool */
private $wasHandled; private $wasAcknowledged;
public function __construct(ProxyDataInterface $proxyData) public function __construct(ProxyDataInterface $proxyData)
{ {
$this->proxyData = $proxyData; $this->proxyData = $proxyData;
$this->wasHandled = false; $this->wasAcknowledged = false;
} }
public function getProxyData(): ProxyDataInterface public function getProxyData(): ProxyDataInterface
...@@ -28,18 +28,18 @@ class ProxyDataEvent extends Event ...@@ -28,18 +28,18 @@ class ProxyDataEvent extends Event
} }
/** /**
* Indicate, that the event was handled, e.g. there was an event subscriber for the requested proxy data namespace. * Acknowledge the event, i.e. tell that there was an event subscriber responsible for the requested proxy data namespace.
*/ */
public function setHandled(): void public function acknowledge(): void
{ {
$this->wasHandled = true; $this->wasAcknowledged = true;
} }
/** /**
* True, if the event was handled, e.g. there was an event subscriber for the requested proxy data namespace, false otherwise. * True, if the event was acknowledged, e.g. there was an event subscriber responsible for the requested proxy data namespace, false otherwise.
*/ */
public function wasHandled(): bool public function wasAcknowledged(): bool
{ {
return $this->wasHandled; return $this->wasAcknowledged;
} }
} }
...@@ -22,11 +22,22 @@ class ProxyDataEventSubscriber extends AbstractProxyDataEventSubscriber ...@@ -22,11 +22,22 @@ class ProxyDataEventSubscriber extends AbstractProxyDataEventSubscriber
*/ */
private $provider; private $provider;
/** @var bool */
private static $isCurrentlyActive = false;
public function __construct(AuthorizationDataProviderProvider $provider) public function __construct(AuthorizationDataProviderProvider $provider)
{ {
$this->provider = $provider; $this->provider = $provider;
} }
/**
* Indicates, that the event subscriber is currently busy handling a proxy data event.
*/
public static function isCurrentlyActive(): bool
{
return self::$isCurrentlyActive;
}
protected function isFunctionDefined(string $functionName): bool protected function isFunctionDefined(string $functionName): bool
{ {
return return
...@@ -46,6 +57,8 @@ class ProxyDataEventSubscriber extends AbstractProxyDataEventSubscriber ...@@ -46,6 +57,8 @@ class ProxyDataEventSubscriber extends AbstractProxyDataEventSubscriber
*/ */
protected function callFunction(string $functionName, array $arguments): ?array protected function callFunction(string $functionName, array $arguments): ?array
{ {
try {
self::$isCurrentlyActive = true;
$returnValue = null; $returnValue = null;
switch ($functionName) { switch ($functionName) {
...@@ -58,6 +71,9 @@ class ProxyDataEventSubscriber extends AbstractProxyDataEventSubscriber ...@@ -58,6 +71,9 @@ class ProxyDataEventSubscriber extends AbstractProxyDataEventSubscriber
} }
return $returnValue; return $returnValue;
} finally {
self::$isCurrentlyActive = false;
}
} }
private function getAvailableAttributes(): array private function getAvailableAttributes(): array
......
...@@ -93,3 +93,7 @@ services: ...@@ -93,3 +93,7 @@ services:
Dbp\Relay\CoreBundle\Authorization\DebugCommand: Dbp\Relay\CoreBundle\Authorization\DebugCommand:
autowire: true autowire: true
autoconfigure: true autoconfigure: true
Dbp\Relay\CoreBundle\ProxyApi\ProxyDataEventSubscriber:
autowire: true
autoconfigure: true
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment