signUri example

private SystemConfigService $systemConfigService;

    protected function setUp(): void
    {
        $this->secret = 'lksf#$osck$FSFDSF#$#F43jjidjsfisj-333';
        $this->querySigner = $this->getContainer()->get(QuerySigner::class);
        $this->systemConfigService = $this->getContainer()->get(SystemConfigService::class);
    }

    public function testSignUri(): void
    {
        $signedUri = $this->querySigner->signUri('http://app.url/?foo=bar', $this->secret, Context::createDefaultContext());
        parse_str($signedUri->getQuery()$signedQuery);

        static::assertArrayHasKey('shop-id', $signedQuery);
        $shopConfig = $this->systemConfigService->get(ShopIdProvider::SHOP_ID_SYSTEM_CONFIG_KEY);
        static::assertIsArray($shopConfig);
        static::assertArrayHasKey('value', $shopConfig);
        $shopId = $shopConfig['value'];
        static::assertIsString($shopId);
        static::assertEquals($shopId$signedQuery['shop-id']);

        static::assertArrayHasKey('shop-url', $signedQuery);
        
'aclRole' => [
                    'name' => self::EXISTING_APP_NAME,
                    'privileges' => [],
                ],
            ],
        ]$this->context);

        if ($expectAppNotFoundError) {
            $this->expectException(AppByNameNotFoundException::class);
        }

        $response = $this->adminExtensionApiController->signUri($requestDataBag$this->context);

        if ($expectAppNotFoundError) {
            return;
        }

        static::assertSame(Response::HTTP_OK, $response->getStatusCode());

        $content = $response->getContent();
        static::assertIsString($content);
        $data = \json_decode($content, true, 512, \JSON_THROW_ON_ERROR);
        static::assertIsArray($data);
        
if ($registeredSource === null) {
            return null;
        }

        $secret = $app->getAppSecret() ?? '';

        return $this->sign($registeredSource$secret$context);
    }

    private function sign(string $source, string $secret, Context $context): string
    {
        return (string) $this->querySigner->signUri($source$secret$context);
    }
}
/** @var AppEntity|null $app */
        $app = $this->appRepository->search($criteria$context)->first();
        if ($app === null) {
            throw new AppByNameNotFoundException($appName);
        }

        $secret = $app->getAppSecret();
        if ($secret === null) {
            throw new MissingAppSecretException();
        }

        $uri = $this->querySigner->signUri($requestDataBag->get('uri')$secret$context)->__toString();

        return new JsonResponse([
            'uri' => $uri,
        ]);
    }
}


    /** * @param array<mixed> $payload */
    public function create(AppAction $action, array $payload, Context $context): ActionButtonResponse
    {
        $this->validate($payload$action->getActionId());

        $appSecret = $action->getAppSecret();
        if ($appSecret) {
            $payload['redirectUrl'] = (string) $this->signer->signUri($payload['redirectUrl']$appSecret$context);
        }

        $response = new OpenNewTabResponse();
        $response->assign($payload);

        return $response;
    }

    /** * @param array<mixed> $payload */
    


    /** * @param array<mixed> $payload */
    public function create(AppAction $action, array $payload, Context $context): ActionButtonResponse
    {
        $this->validate($payload$action->getActionId());

        $appSecret = $action->getAppSecret();
        if ($appSecret) {
            $payload['iframeUrl'] = (string) $this->signer->signUri($payload['iframeUrl']$appSecret$context);
        }

        $response = new OpenModalResponse();
        $response->assign($payload);

        return $response;
    }

    /** * @param array<mixed> $payload */
    
Home | Imprint | This part of the site doesn't use cookies.