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
No related branches found
No related tags found
No related merge requests found
......@@ -13,8 +13,8 @@ class ApiConnection
{
public const API_URL_CONFIG_PARAMETER = 'api_url';
public const KEYCLOAK_SERVER_URL_CONFIG_PARAMETER = 'keycloak_server_url';
public const KEYCLOAK_REALM_CONFIG_PARAMETER = 'keycloak_realm';
public const OIDC_SERVER_URL_CONFIG_PARAMETER = 'oidc_server_url';
public const OIDC_REALM_CONFIG_PARAMETER = 'oidc_realm';
public const CLIENT_ID_CONFIG_PARAMETER = 'client_id';
public const CLIENT_SECRET_CONFIG_PARAMETER = 'client_secret';
......@@ -111,8 +111,8 @@ class ApiConnection
private function getAccessToken(): string
{
if ($this->accessToken === null) {
$idServerUrl = $this->config[self::KEYCLOAK_SERVER_URL_CONFIG_PARAMETER];
$idServerRealm = $this->config[self::KEYCLOAK_REALM_CONFIG_PARAMETER];
$idServerUrl = $this->config[self::OIDC_SERVER_URL_CONFIG_PARAMETER];
$idServerRealm = $this->config[self::OIDC_REALM_CONFIG_PARAMETER];
$clientId = $this->config[self::CLIENT_ID_CONFIG_PARAMETER];
$clientSecret = $this->config[self::CLIENT_SECRET_CONFIG_PARAMETER];
......
......@@ -15,7 +15,7 @@ abstract class AbstractProxyDataEventSubscriber implements EventSubscriberInterf
public static function getSubscribedEvents(): array
{
return [
ProxyApi::PROXY_DATA_EVENT_NAME.static::NAMESPACE => 'onProxyDataEvent',
ProxyDataEvent::NAME.'.'.static::NAMESPACE => 'onProxyDataEvent',
];
}
......@@ -24,7 +24,7 @@ abstract class AbstractProxyDataEventSubscriber implements EventSubscriberInterf
*/
public function onProxyDataEvent(ProxyDataEvent $event): void
{
$event->setHandled();
$event->acknowledge();
$proxyData = $event->getProxyData();
$functionName = $proxyData->getFunctionName();
$arguments = $proxyData->getArguments();
......
......@@ -6,8 +6,6 @@ namespace Dbp\Relay\CoreBundle\ProxyApi;
class ProxyApi
{
public const PROXY_DATA_EVENT_NAME = '';
public const PROXY_DATA_RETURN_VALUE_KEY = 'data';
public const PROXY_DATA_ERRORS_KEY = 'errors';
}
......@@ -8,18 +8,18 @@ use Symfony\Contracts\EventDispatcher\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 */
private $proxyData;
/** @var bool */
private $wasHandled;
private $wasAcknowledged;
public function __construct(ProxyDataInterface $proxyData)
{
$this->proxyData = $proxyData;
$this->wasHandled = false;
$this->wasAcknowledged = false;
}
public function getProxyData(): ProxyDataInterface
......@@ -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
*/
private $provider;
/** @var bool */
private static $isCurrentlyActive = false;
public function __construct(AuthorizationDataProviderProvider $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
{
return
......@@ -46,6 +57,8 @@ class ProxyDataEventSubscriber extends AbstractProxyDataEventSubscriber
*/
protected function callFunction(string $functionName, array $arguments): ?array
{
try {
self::$isCurrentlyActive = true;
$returnValue = null;
switch ($functionName) {
......@@ -58,6 +71,9 @@ class ProxyDataEventSubscriber extends AbstractProxyDataEventSubscriber
}
return $returnValue;
} finally {
self::$isCurrentlyActive = false;
}
}
private function getAvailableAttributes(): array
......
......@@ -93,3 +93,7 @@ services:
Dbp\Relay\CoreBundle\Authorization\DebugCommand:
autowire: 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