From 4672c4bb8ac7dc2d0c7904d01f30263e955acab6 Mon Sep 17 00:00:00 2001 From: Michiel de Jong Date: Mon, 19 Oct 2020 13:48:46 +0200 Subject: [PATCH 01/25] Build and run solid-crud tests --- run-solid-test-suite.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/run-solid-test-suite.sh b/run-solid-test-suite.sh index 838e118..08d36b3 100644 --- a/run-solid-test-suite.sh +++ b/run-solid-test-suite.sh @@ -9,6 +9,7 @@ docker build -t server . docker run -d --name server --network=testnet server docker build -t webid-provider https://github.com/pdsinterop/test-suites.git#master:/testers/webid-provider +docker build -t solid-crud https://github.com/pdsinterop/test-suites.git#master:/testers/solid-crud docker build -t cookie https://github.com/pdsinterop/test-suites.git#master:servers/php-solid-server/cookie wget -O /tmp/env-vars-for-test-image.list https://raw.githubusercontent.com/solid/test-suite/master/servers/php-solid-server/env.list until docker run --rm --network=testnet webid-provider curl -kI https://server 2> /dev/null > /dev/null @@ -25,6 +26,7 @@ echo Getting cookie... export COOKIE="`docker run --cap-add=SYS_ADMIN --network=testnet --env-file /tmp/env-vars-for-test-image.list cookie`" echo "Running webid-provider tests with cookie $COOKIE" docker run --rm --network=testnet --env COOKIE="$COOKIE" --env-file /tmp/env-vars-for-test-image.list webid-provider +docker run --rm --network=testnet --env COOKIE="$COOKIE" --env-file /tmp/env-vars-for-test-image.list solid-crud # rm /tmp/env-vars-for-test-image.list # docker stop server # docker rm server From b04e5778d2e804d906ae09420e9a774197227af1 Mon Sep 17 00:00:00 2001 From: Michiel de Jong Date: Mon, 19 Oct 2020 14:15:25 +0200 Subject: [PATCH 02/25] skip webid-provider tests that currently still fail in master --- run-solid-test-suite.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-solid-test-suite.sh b/run-solid-test-suite.sh index 08d36b3..b254f16 100644 --- a/run-solid-test-suite.sh +++ b/run-solid-test-suite.sh @@ -25,7 +25,7 @@ docker logs server echo Getting cookie... export COOKIE="`docker run --cap-add=SYS_ADMIN --network=testnet --env-file /tmp/env-vars-for-test-image.list cookie`" echo "Running webid-provider tests with cookie $COOKIE" -docker run --rm --network=testnet --env COOKIE="$COOKIE" --env-file /tmp/env-vars-for-test-image.list webid-provider +# docker run --rm --network=testnet --env COOKIE="$COOKIE" --env-file /tmp/env-vars-for-test-image.list webid-provider docker run --rm --network=testnet --env COOKIE="$COOKIE" --env-file /tmp/env-vars-for-test-image.list solid-crud # rm /tmp/env-vars-for-test-image.list # docker stop server From 6416a4778ae131bc0297c23cd4a0fdb1c2fc60d5 Mon Sep 17 00:00:00 2001 From: Michiel de Jong Date: Fri, 23 Oct 2020 09:59:40 +0200 Subject: [PATCH 03/25] Run solid-crud-tests as per https://github.com/solid/solid-crud-tests#with-public-access --- run-solid-test-suite.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-solid-test-suite.sh b/run-solid-test-suite.sh index b254f16..c22b1ce 100644 --- a/run-solid-test-suite.sh +++ b/run-solid-test-suite.sh @@ -26,7 +26,7 @@ echo Getting cookie... export COOKIE="`docker run --cap-add=SYS_ADMIN --network=testnet --env-file /tmp/env-vars-for-test-image.list cookie`" echo "Running webid-provider tests with cookie $COOKIE" # docker run --rm --network=testnet --env COOKIE="$COOKIE" --env-file /tmp/env-vars-for-test-image.list webid-provider -docker run --rm --network=testnet --env COOKIE="$COOKIE" --env-file /tmp/env-vars-for-test-image.list solid-crud +docker run --rm --network=testnet --env-file /tmp/env-vars-for-test-image.list solid-crud # rm /tmp/env-vars-for-test-image.list # docker stop server # docker rm server From 2afd2f13d99e87c71294adca74d5346d9b1e40a7 Mon Sep 17 00:00:00 2001 From: Michiel de Jong Date: Fri, 23 Oct 2020 10:06:54 +0200 Subject: [PATCH 04/25] load env.list from pdsinterop/test-suites --- run-solid-test-suite.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-solid-test-suite.sh b/run-solid-test-suite.sh index c22b1ce..d35639a 100644 --- a/run-solid-test-suite.sh +++ b/run-solid-test-suite.sh @@ -11,7 +11,7 @@ docker run -d --name server --network=testnet server docker build -t webid-provider https://github.com/pdsinterop/test-suites.git#master:/testers/webid-provider docker build -t solid-crud https://github.com/pdsinterop/test-suites.git#master:/testers/solid-crud docker build -t cookie https://github.com/pdsinterop/test-suites.git#master:servers/php-solid-server/cookie -wget -O /tmp/env-vars-for-test-image.list https://raw.githubusercontent.com/solid/test-suite/master/servers/php-solid-server/env.list +wget -O /tmp/env-vars-for-test-image.list https://raw.githubusercontent.com/pdsinterop/test-suites/master/servers/php-solid-server/env.list until docker run --rm --network=testnet webid-provider curl -kI https://server 2> /dev/null > /dev/null do echo Waiting for server to start, this can take up to a minute ... From 5c72a5648210336e7dce0c163def129daccec180 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Mon, 26 Oct 2020 14:26:16 +0100 Subject: [PATCH 05/25] add specific storage url --- tests/fixtures/foaf.rdf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/fixtures/foaf.rdf b/tests/fixtures/foaf.rdf index 86a1100..8816349 100644 --- a/tests/fixtures/foaf.rdf +++ b/tests/fixtures/foaf.rdf @@ -9,8 +9,8 @@ > - - + + From 554503170f4786a31bc5b580f3347d159faecd71 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Mon, 26 Oct 2020 14:26:31 +0100 Subject: [PATCH 06/25] adding storage controller --- src/Controller/StorageController.php | 32 ++++++++++++++++++++++++++++ web/index.php | 3 +++ 2 files changed, 35 insertions(+) create mode 100644 src/Controller/StorageController.php diff --git a/src/Controller/StorageController.php b/src/Controller/StorageController.php new file mode 100644 index 0000000..1978a65 --- /dev/null +++ b/src/Controller/StorageController.php @@ -0,0 +1,32 @@ +. +@prefix inbox: <>. +@prefix ldp: . +@prefix terms: . +@prefix XML: . +@prefix st: . + +inbox: + a ldp:BasicContainer, ldp:Container, ldp:Resource; + terms:modified "2019-12-20T14:52:54Z"^^XML:dateTime; + st:mtime 1576853574.389; + st:size 4096. +EOF; + $response = $this->getResponse(); + + $response->getBody()->write($body); + return $response + ->withHeader("Content-type", "text/turtle"); + } +} diff --git a/web/index.php b/web/index.php index 2b6a3ba..30b036f 100644 --- a/web/index.php +++ b/web/index.php @@ -31,6 +31,7 @@ use Pdsinterop\Solid\Controller\Profile\CardController; use Pdsinterop\Solid\Controller\Profile\ProfileController; use Pdsinterop\Solid\Controller\RegisterController; +use Pdsinterop\Solid\Controller\StorageController; use Pdsinterop\Solid\Controller\TokenController; use Psr\Http\Message\ResponseInterface; @@ -95,6 +96,7 @@ OpenidController::class, ProfileController::class, RegisterController::class, + StorageController::class, TokenController::class, ]; @@ -146,6 +148,7 @@ $router->map('GET', '/authorize', AuthorizeController::class)->setScheme($scheme); $router->map('GET', '/sharing/{clientId}/', ApprovalController::class)->setScheme($scheme); $router->map('POST', '/sharing/{clientId}/', HandleApprovalController::class)->setScheme($scheme); +$router->map('GET', '/storage/', StorageController::class)->setScheme($scheme); $router->map('POST', '/token', TokenController::class)->setScheme($scheme); $router->map('POST', '/token/', TokenController::class)->setScheme($scheme); From 4a43e9ae6508097a895b45d704b3dc08fc465b51 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Mon, 26 Oct 2020 14:36:51 +0100 Subject: [PATCH 07/25] typofix --- src/Controller/StorageController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controller/StorageController.php b/src/Controller/StorageController.php index 1978a65..d54c0a9 100644 --- a/src/Controller/StorageController.php +++ b/src/Controller/StorageController.php @@ -5,7 +5,7 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; -class InboxController extends ServerController +class StorageController extends ServerController { final public function __invoke(ServerRequestInterface $request, array $args): ResponseInterface { From a9fbbfd085248ceed0aa825f4911f3700c7db959 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Wed, 28 Oct 2020 13:45:32 +0100 Subject: [PATCH 08/25] added solid-crud in composer added the solid-crud handler in for /storage/ requests --- composer.json | 3 ++- web/index.php | 69 +++++++++++++++++++++++++++++---------------------- 2 files changed, 42 insertions(+), 30 deletions(-) diff --git a/composer.json b/composer.json index 5144739..3f82cd4 100644 --- a/composer.json +++ b/composer.json @@ -28,8 +28,9 @@ "league/flysystem": "^1.0.", "league/oauth2-server": "^8.0", "league/route": "^4.5", - "pdsinterop/flysystem-rdf": "dev-dev", + "pdsinterop/flysystem-rdf": "dev-master", "pdsinterop/solid-auth": "dev-master", + "pdsinterop/solid-crud": "dev-master", "php-http/httplug": "^2.1", "phptal/phptal": "^1.4" }, diff --git a/web/index.php b/web/index.php index 30b036f..ce80fb8 100644 --- a/web/index.php +++ b/web/index.php @@ -16,7 +16,6 @@ use League\Route\Http\Exception\NotFoundException; use League\Route\Router; use League\Route\Strategy\ApplicationStrategy; - use Pdsinterop\Solid\Controller\AddSlashToPathController; use Pdsinterop\Solid\Controller\AuthorizeController; use Pdsinterop\Solid\Controller\ApprovalController; @@ -33,6 +32,7 @@ use Pdsinterop\Solid\Controller\RegisterController; use Pdsinterop\Solid\Controller\StorageController; use Pdsinterop\Solid\Controller\TokenController; +use Pdsinterop\Solid\Resources\Server; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; @@ -148,38 +148,49 @@ $router->map('GET', '/authorize', AuthorizeController::class)->setScheme($scheme); $router->map('GET', '/sharing/{clientId}/', ApprovalController::class)->setScheme($scheme); $router->map('POST', '/sharing/{clientId}/', HandleApprovalController::class)->setScheme($scheme); +$router->map('GET', '/storage', AddSlashToPathController::class)->setScheme($scheme); $router->map('GET', '/storage/', StorageController::class)->setScheme($scheme); +$router->map('GET', '/storage/{path}', StorageController::class)->setScheme($scheme); $router->map('POST', '/token', TokenController::class)->setScheme($scheme); $router->map('POST', '/token/', TokenController::class)->setScheme($scheme); -try { - $response = $router->dispatch($request); -} catch (HttpException $exception) { - $status = $exception->getStatusCode(); - - $message = 'Yeah, that\'s an error.'; - if ($exception instanceof NotFoundException) { - $message = 'No such page.'; - } - - $html = "

{$message}

{$exception->getMessage()} ({$status})

"; - - if (getenv('ENVIRONMENT') === 'development') { - $html .= "
{$exception->getTraceAsString()}
"; - } - - $response = new HtmlResponse($html, $status, $exception->getHeaders()); -} catch (\Exception $exception) { - $html = "

Oh-no! The developers messed up!

{$exception->getMessage()}

"; - - if (getenv('ENVIRONMENT') === 'development') { - $html .= - "

{$exception->getFile()}:{$exception->getLine()}

" . - "
{$exception->getTraceAsString()}
" - ; - } - - $response = new HtmlResponse($html, 500, []); +$path = $request->getUri()->getPath(); +$target = $request->getMethod() . $request->getRequestTarget(); +if ($path !== "/storage/" && strpos($path, '/storage/') === 0) { + // Route starts with our data-source prefix + $response = new \Laminas\Diactoros\Response(); + $server = new \Pdsinterop\Solid\Resources\Server($filesystem, $response); + $response = $server->respondToRequest($request); +} else { + try { + $response = $router->dispatch($request); + } catch (HttpException $exception) { + $status = $exception->getStatusCode(); + + $message = 'Yeah, that\'s an error.'; + if ($exception instanceof NotFoundException) { + $message = 'No such page.'; + } + + $html = "

{$message}

{$exception->getMessage()} ({$status})

"; + + if (getenv('ENVIRONMENT') === 'development') { + $html .= "
{$exception->getTraceAsString()}
"; + } + + $response = new HtmlResponse($html, $status, $exception->getHeaders()); + } catch (\Exception $exception) { + $html = "

Oh-no! The developers messed up!

{$exception->getMessage()}

"; + + if (getenv('ENVIRONMENT') === 'development') { + $html .= + "

{$exception->getFile()}:{$exception->getLine()}

" . + "
{$exception->getTraceAsString()}
" + ; + } + + $response = new HtmlResponse($html, 500, []); + } } // send the response to the browser From d982d3f5b2f9d15ffdb5c36e0d9e87255776e7c3 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Sat, 31 Oct 2020 09:22:43 +0100 Subject: [PATCH 09/25] adding websocket for pubsub --- composer.json | 4 +- websocket.php | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 websocket.php diff --git a/composer.json b/composer.json index 3f82cd4..cf8f934 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,9 @@ "pdsinterop/solid-auth": "dev-master", "pdsinterop/solid-crud": "dev-master", "php-http/httplug": "^2.1", - "phptal/phptal": "^1.4" + "phptal/phptal": "^1.4", + "cboden/ratchet": "^0.4", + "textalk/websocket": "^1.4" }, "require-dev": { "phpunit/phpunit": "*" diff --git a/websocket.php b/websocket.php new file mode 100644 index 0000000..42071ab --- /dev/null +++ b/websocket.php @@ -0,0 +1,100 @@ +clients = new \SplObjectStorage; + $this->subscriptions = array(); + } + + public function onOpen(ConnectionInterface $conn) { + + // Store the new connection in $this->clients + $this->clients->attach($conn); + echo "New connection! ({$conn->resourceId})\n"; + } + + public function onMessage(ConnectionInterface $from, $message) { + $messageInfo = explode(" ", $message); + $command = $messageInfo[0]; + $body = trim($messageInfo[1]); + + switch ($command) { + case "auth": + case "dpop": + // FIXME: we should check that the client is allowed to listen + break; + case "sub": + echo "Client sub for $body\n"; + if (!isset($this->subscriptions[$body])) { + $this->subscriptions[$body] = array(); + } + $this->subscriptions[$body][] = $from; + $from->send("ack $body"); + break; + case "pub": + echo "Client pub for $body\n"; + if (isset($this->subscriptions[$body])) { + foreach ( $this->subscriptions[$body] as $client ) { + $client->send("pub $body"); + } + } + break; + default: + echo "Client $from->resourceId said $message\n"; + foreach ( $this->clients as $client ) { + + if ( $from->resourceId == $client->resourceId ) { + continue; + } + + $client->send("Client $from->resourceId said $message\n"); + } + break; + } + } + + public function onClose(ConnectionInterface $conn) { + echo "Client $conn->resourceId left\n"; + foreach ($this->subscriptions as $url => $subscribers) { + foreach ($subscribers as $key => $client) { + if ($client->resourceId == $conn->resourceId) { + echo "Removing subscription for $url\n"; + unset($subscribers[$url][$key]); + } + } + } + } + + public function onError(ConnectionInterface $conn, \Exception $e) { + foreach ($this->subscriptions as $url => $subscribers) { + foreach ($subscribers as $key => $client) { + if ($client->resourceId == $conn->resourceId) { + echo "Removing subscription for $url\n"; + unset($subscribers[$url][$key]); + } + } + } + } +} + +$server = IoServer::factory( + new HttpServer( + new WsServer( + new Socket() + ) + ), + SOCKET_PORT +); + +$server->run(); From befc5cb371a6839c2a0780c570befa866c2ed7fb Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Mon, 2 Nov 2020 14:55:31 +0100 Subject: [PATCH 10/25] make sure the config dir is writable for apache --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 79d7f76..347f0b0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,3 +20,4 @@ WORKDIR /app RUN php /install/composer.phar install --no-dev --prefer-dist COPY site.conf /etc/apache2/sites-enabled/site.conf EXPOSE 443 +RUN chown www-data:www-data config From 111215b0d863e98e2799527c1e5fda199797488b Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Mon, 2 Nov 2020 15:29:16 +0100 Subject: [PATCH 11/25] merging from master --- run-solid-test-suite.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/run-solid-test-suite.sh b/run-solid-test-suite.sh index 4b65be5..b48a5ff 100644 --- a/run-solid-test-suite.sh +++ b/run-solid-test-suite.sh @@ -2,15 +2,18 @@ set -e # Run the Solid test-suite -docker network create testnet +#docker network create testnet # Build and start Nextcloud server with code from current repo contents: docker build -t server . docker build -t webid-provider https://github.com/pdsinterop/test-suites.git#master:/testers/webid-provider -docker build -t solid-crud https://github.com/pdsinterop/test-suites.git#master:/testers/solid-crud +#docker build -t solid-crud https://github.com/pdsinterop/test-suites.git#master:/testers/solid-crud +docker build --no-cache -t solid-crud https://github.com/pdsinterop/test-suites.git#master:/testers/solid-crud docker build -t cookie https://github.com/pdsinterop/test-suites.git#master:servers/php-solid-server/cookie -wget -O /tmp/env-vars-for-test-image.list https://raw.githubusercontent.com/pdsinterop/test-suites/master/servers/php-solid-server/env.list + +# wget -O /tmp/env-vars-for-test-image.list https://raw.githubusercontent.com/pdsinterop/test-suites/master/servers/php-solid-server/env.list +curl https://raw.githubusercontent.com/pdsinterop/test-suites/master/servers/php-solid-server/env.list -o /tmp/env-vars-for-test-image.list docker run -d --name server --network=testnet --env-file /tmp/env-vars-for-test-image.list server From dbda405ea8e6c2117ba87e99369ee70a6cda02d3 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Mon, 2 Nov 2020 15:39:39 +0100 Subject: [PATCH 12/25] do create testnet --- run-solid-test-suite.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-solid-test-suite.sh b/run-solid-test-suite.sh index b48a5ff..eeae0e2 100644 --- a/run-solid-test-suite.sh +++ b/run-solid-test-suite.sh @@ -2,7 +2,7 @@ set -e # Run the Solid test-suite -#docker network create testnet +docker network create testnet # Build and start Nextcloud server with code from current repo contents: docker build -t server . From 7aa57e0d358874c77ec575f728d473185f05efc0 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Wed, 4 Nov 2020 15:57:00 +0100 Subject: [PATCH 13/25] use proper routing for the resource server --- web/index.php | 55 ++++----------------------------------------------- 1 file changed, 4 insertions(+), 51 deletions(-) diff --git a/web/index.php b/web/index.php index 800475b..1351492 100644 --- a/web/index.php +++ b/web/index.php @@ -31,7 +31,6 @@ use Pdsinterop\Solid\Controller\Profile\ProfileController; use Pdsinterop\Solid\Controller\RegisterController; use Pdsinterop\Solid\Controller\ResourceController; -use Pdsinterop\Solid\Controller\StorageController; use Pdsinterop\Solid\Controller\TokenController; use Pdsinterop\Solid\Resources\Server as ResourceServer; @@ -85,8 +84,6 @@ $container->add(ResourceController::class, function () use ($container) { $filesystem = $container-> get(FilesystemInterface::class); - require_once __DIR__ . '/../lib/solid-crud/src/Server.php'; - $server = new ResourceServer($filesystem, new Response()); return new ResourceController($server); @@ -94,11 +91,11 @@ $controllers = [ AddSlashToPathController::class, - ApprovalController::class, + ApprovalController::class, AuthorizeController::class, CardController::class, CorsController::class, - HandleApprovalController::class, + HandleApprovalController::class, HelloWorldController::class, HttpToHttpsController::class, JwksController::class, @@ -107,8 +104,7 @@ OpenidController::class, ProfileController::class, RegisterController::class, - StorageController::class, - TokenController::class, + TokenController::class, ]; $traits = [ @@ -159,51 +155,9 @@ $router->map('GET', '/authorize', AuthorizeController::class)->setScheme($scheme); $router->map('GET', '/sharing/{clientId}/', ApprovalController::class)->setScheme($scheme); $router->map('POST', '/sharing/{clientId}/', HandleApprovalController::class)->setScheme($scheme); -$router->map('GET', '/storage', AddSlashToPathController::class)->setScheme($scheme); -$router->map('GET', '/storage/', StorageController::class)->setScheme($scheme); -$router->map('GET', '/storage/{path}', StorageController::class)->setScheme($scheme); $router->map('POST', '/token', TokenController::class)->setScheme($scheme); $router->map('POST', '/token/', TokenController::class)->setScheme($scheme); - -$path = $request->getUri()->getPath(); -$target = $request->getMethod() . $request->getRequestTarget(); -if ($path !== "/storage/" && strpos($path, '/storage/') === 0) { - // Route starts with our data-source prefix - $response = new \Laminas\Diactoros\Response(); - $server = new \Pdsinterop\Solid\Resources\Server($filesystem, $response); - $response = $server->respondToRequest($request); -} else { - try { - $response = $router->dispatch($request); - } catch (HttpException $exception) { - $status = $exception->getStatusCode(); - - $message = 'Yeah, that\'s an error.'; - if ($exception instanceof NotFoundException) { - $message = 'No such page.'; - } - - $html = "

{$message}

{$exception->getMessage()} ({$status})

"; - - if (getenv('ENVIRONMENT') === 'development') { - $html .= "
{$exception->getTraceAsString()}
"; - } - - $response = new HtmlResponse($html, $status, $exception->getHeaders()); - } catch (\Exception $exception) { - $html = "

Oh-no! The developers messed up!

{$exception->getMessage()}

"; - - if (getenv('ENVIRONMENT') === 'development') { - $html .= - "

{$exception->getFile()}:{$exception->getLine()}

" . - "
{$exception->getTraceAsString()}
" - ; - } - - $response = new HtmlResponse($html, 500, []); - } -/* -$router->group('/data', static function (\League\Route\RouteGroup $group) { +$router->group('/storage', static function (\League\Route\RouteGroup $group) { $methods = [ 'DELETE', 'GET', @@ -248,7 +202,6 @@ } $response = new HtmlResponse($html, 500, []); -*/ } // send the response to the browser From 23596a49bd49a964f8137cbd26c616d9759703a0 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Wed, 4 Nov 2020 16:13:55 +0100 Subject: [PATCH 14/25] moving websocket to own repo removing websocket dependancy here, is handled in solid-crud itself --- composer.json | 4 +- websocket.php | 100 -------------------------------------------------- 2 files changed, 1 insertion(+), 103 deletions(-) delete mode 100644 websocket.php diff --git a/composer.json b/composer.json index 44f863d..84aedd0 100644 --- a/composer.json +++ b/composer.json @@ -32,9 +32,7 @@ "pdsinterop/solid-auth": "dev-master", "pdsinterop/solid-crud": "dev-master", "php-http/httplug": "^2.1", - "phptal/phptal": "^1.4", - "cboden/ratchet": "^0.4", - "textalk/websocket": "^1.4" + "phptal/phptal": "^1.4" }, "require-dev": { "phpunit/phpunit": "*" diff --git a/websocket.php b/websocket.php deleted file mode 100644 index 42071ab..0000000 --- a/websocket.php +++ /dev/null @@ -1,100 +0,0 @@ -clients = new \SplObjectStorage; - $this->subscriptions = array(); - } - - public function onOpen(ConnectionInterface $conn) { - - // Store the new connection in $this->clients - $this->clients->attach($conn); - echo "New connection! ({$conn->resourceId})\n"; - } - - public function onMessage(ConnectionInterface $from, $message) { - $messageInfo = explode(" ", $message); - $command = $messageInfo[0]; - $body = trim($messageInfo[1]); - - switch ($command) { - case "auth": - case "dpop": - // FIXME: we should check that the client is allowed to listen - break; - case "sub": - echo "Client sub for $body\n"; - if (!isset($this->subscriptions[$body])) { - $this->subscriptions[$body] = array(); - } - $this->subscriptions[$body][] = $from; - $from->send("ack $body"); - break; - case "pub": - echo "Client pub for $body\n"; - if (isset($this->subscriptions[$body])) { - foreach ( $this->subscriptions[$body] as $client ) { - $client->send("pub $body"); - } - } - break; - default: - echo "Client $from->resourceId said $message\n"; - foreach ( $this->clients as $client ) { - - if ( $from->resourceId == $client->resourceId ) { - continue; - } - - $client->send("Client $from->resourceId said $message\n"); - } - break; - } - } - - public function onClose(ConnectionInterface $conn) { - echo "Client $conn->resourceId left\n"; - foreach ($this->subscriptions as $url => $subscribers) { - foreach ($subscribers as $key => $client) { - if ($client->resourceId == $conn->resourceId) { - echo "Removing subscription for $url\n"; - unset($subscribers[$url][$key]); - } - } - } - } - - public function onError(ConnectionInterface $conn, \Exception $e) { - foreach ($this->subscriptions as $url => $subscribers) { - foreach ($subscribers as $key => $client) { - if ($client->resourceId == $conn->resourceId) { - echo "Removing subscription for $url\n"; - unset($subscribers[$url][$key]); - } - } - } - } -} - -$server = IoServer::factory( - new HttpServer( - new WsServer( - new Socket() - ) - ), - SOCKET_PORT -); - -$server->run(); From d31821161611c08739c3f548cc95894760a6aba6 Mon Sep 17 00:00:00 2001 From: Auke van Slooten Date: Wed, 4 Nov 2020 16:33:44 +0100 Subject: [PATCH 15/25] added php-solid-pubsub-server docker container --- run-solid-test-suite.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) mode change 100644 => 100755 run-solid-test-suite.sh diff --git a/run-solid-test-suite.sh b/run-solid-test-suite.sh old mode 100644 new mode 100755 index eeae0e2..832fd5f --- a/run-solid-test-suite.sh +++ b/run-solid-test-suite.sh @@ -5,27 +5,30 @@ set -e docker network create testnet # Build and start Nextcloud server with code from current repo contents: -docker build -t server . +docker build -t standalone-solid-server . docker build -t webid-provider https://github.com/pdsinterop/test-suites.git#master:/testers/webid-provider #docker build -t solid-crud https://github.com/pdsinterop/test-suites.git#master:/testers/solid-crud docker build --no-cache -t solid-crud https://github.com/pdsinterop/test-suites.git#master:/testers/solid-crud docker build -t cookie https://github.com/pdsinterop/test-suites.git#master:servers/php-solid-server/cookie +docker build -t pubsub-server https://github.com/pdsinterop/php-solid-pubsub-server.git#master # wget -O /tmp/env-vars-for-test-image.list https://raw.githubusercontent.com/pdsinterop/test-suites/master/servers/php-solid-server/env.list curl https://raw.githubusercontent.com/pdsinterop/test-suites/master/servers/php-solid-server/env.list -o /tmp/env-vars-for-test-image.list -docker run -d --name server --network=testnet --env-file /tmp/env-vars-for-test-image.list server +docker run -d --name server --network=testnet --env-file /tmp/env-vars-for-test-image.list standalone-solid-server + +docker run -d --name pubsub --network=testnet pubsub-server until docker run --rm --network=testnet webid-provider curl -kI https://server 2> /dev/null > /dev/null do echo Waiting for server to start, this can take up to a minute ... docker ps -a - docker logs server || true + docker logs standalone-solid-server || true sleep 1 done docker ps -a -docker logs server +docker logs standalone-solid-server echo Getting cookie... export COOKIE="`docker run --cap-add=SYS_ADMIN --network=testnet --env-file /tmp/env-vars-for-test-image.list cookie`" @@ -33,6 +36,6 @@ echo "Running webid-provider tests with cookie $COOKIE" # docker run --rm --network=testnet --env COOKIE="$COOKIE" --env-file /tmp/env-vars-for-test-image.list webid-provider docker run --rm --network=testnet --env-file /tmp/env-vars-for-test-image.list solid-crud # rm /tmp/env-vars-for-test-image.list -# docker stop server -# docker rm server +# docker stop standalone-solid-server +# docker rm standalone-solid-server # docker network remove testnet From 0def9d5b7c7cab9fabeebf5a8b35a2155d9fc625 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Wed, 4 Nov 2020 18:27:29 +0100 Subject: [PATCH 16/25] integration with flysystem rdf content negotiation --- web/index.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/web/index.php b/web/index.php index 1351492..5c1b8d1 100644 --- a/web/index.php +++ b/web/index.php @@ -31,6 +31,7 @@ use Pdsinterop\Solid\Controller\Profile\ProfileController; use Pdsinterop\Solid\Controller\RegisterController; use Pdsinterop\Solid\Controller\ResourceController; +use Pdsinterop\Solid\Controller\StorageController; use Pdsinterop\Solid\Controller\TokenController; use Pdsinterop\Solid\Resources\Server as ResourceServer; @@ -54,21 +55,40 @@ $container->add(ServerRequestInterface::class, Request::class); $container->add(ResponseInterface::class, Response::class); +/* $adapter = new \League\Flysystem\Adapter\Local(__DIR__ . '/../tests/fixtures'); $filesystem = new \League\Flysystem\Filesystem($adapter); $graph = new \EasyRdf_Graph(); $plugin = new \Pdsinterop\Rdf\Flysystem\Plugin\ReadRdf($graph); $filesystem->addPlugin($plugin); +*/ -$container->share(FilesystemInterface::class, function () { +$container->share(FilesystemInterface::class, function () use ($request) { // @FIXME: Filesystem root and the $adapter should be configurable. // Implement this with `$filesystem = \MJRider\FlysystemFactory\create(getenv('STORAGE_ENDPOINT'));` $filesystemRoot = __DIR__ . '/../tests/fixtures'; $adapter = new \League\Flysystem\Adapter\Local($filesystemRoot); - $filesystem = new \League\Flysystem\Filesystem($adapter); $graph = new \EasyRdf_Graph(); + + // Create Formats objects + $formats = new \Pdsinterop\Rdf\Formats(); + + $serverUri = "https://server" . $request->getServerParams()["REQUEST_URI"]; // FIXME: doublecheck that this is the correct url; + + // Create the RDF Adapter + $rdfAdapter = new \Pdsinterop\Rdf\Flysystem\Adapter\Rdf( + $adapter, + $graph, + $formats, + $serverUri + ); + + $filesystem = new \League\Flysystem\Filesystem($rdfAdapter); + + $filesystem->addPlugin(new \Pdsinterop\Rdf\Flysystem\Plugin\AsMime($formats)); + $plugin = new \Pdsinterop\Rdf\Flysystem\Plugin\ReadRdf($graph); $filesystem->addPlugin($plugin); @@ -104,6 +124,7 @@ OpenidController::class, ProfileController::class, RegisterController::class, + StorageController::class, TokenController::class, ]; @@ -170,6 +191,7 @@ array_walk($methods, static function ($method) use (&$group) { $group->map($method, '/', AddSlashToPathController::class); +// $group->map($method, '//', StorageController::class); $group->map($method, '{path:.*}', ResourceController::class); }); })->setScheme($scheme); From 5a01237ffde6d8ba9f4fcec06f82080778817bb6 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Thu, 5 Nov 2020 20:39:00 +0100 Subject: [PATCH 17/25] use servername instead of hardcoded value --- web/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/index.php b/web/index.php index 5c1b8d1..81b2ece 100644 --- a/web/index.php +++ b/web/index.php @@ -75,7 +75,7 @@ // Create Formats objects $formats = new \Pdsinterop\Rdf\Formats(); - $serverUri = "https://server" . $request->getServerParams()["REQUEST_URI"]; // FIXME: doublecheck that this is the correct url; + $serverUri = "https://" . $request->getServerParams()["SERVER_NAME"] . $request->getServerParams()["REQUEST_URI"]; // FIXME: doublecheck that this is the correct url; // Create the RDF Adapter $rdfAdapter = new \Pdsinterop\Rdf\Flysystem\Adapter\Rdf( From f970766b81984add575f68f5fe8e9e6e187e3635 Mon Sep 17 00:00:00 2001 From: Michiel de Jong Date: Thu, 5 Nov 2020 21:35:23 +0100 Subject: [PATCH 18/25] Fix docker logs command in run-solid-test-suite.sh --- run-solid-test-suite.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run-solid-test-suite.sh b/run-solid-test-suite.sh index 832fd5f..16d1d26 100755 --- a/run-solid-test-suite.sh +++ b/run-solid-test-suite.sh @@ -24,11 +24,11 @@ until docker run --rm --network=testnet webid-provider curl -kI https://server 2 do echo Waiting for server to start, this can take up to a minute ... docker ps -a - docker logs standalone-solid-server || true + docker logs server sleep 1 done docker ps -a -docker logs standalone-solid-server +docker logs server echo Getting cookie... export COOKIE="`docker run --cap-add=SYS_ADMIN --network=testnet --env-file /tmp/env-vars-for-test-image.list cookie`" From 796bf68d13f2e4659a08e1a185e7487967f44309 Mon Sep 17 00:00:00 2001 From: Michiel de Jong Date: Thu, 5 Nov 2020 22:26:27 +0100 Subject: [PATCH 19/25] chown all of /app in Dockerfile --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3b9ad2f..c5e8060 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,6 +19,5 @@ ADD . /app WORKDIR /app RUN php /install/composer.phar install --no-dev --prefer-dist COPY site.conf /etc/apache2/sites-enabled/site.conf -RUN chown www-data /app/config +RUN chown -R www-data:www-data /app EXPOSE 443 -RUN chown www-data:www-data config From 6544379e6c8d31c16f5ced729f935bcd956ac6d3 Mon Sep 17 00:00:00 2001 From: Michiel de Jong Date: Thu, 5 Nov 2020 22:55:33 +0100 Subject: [PATCH 20/25] use solid-crud Dockerfile from solid/test-suite --- run-solid-test-suite.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run-solid-test-suite.sh b/run-solid-test-suite.sh index 16d1d26..5d98799 100755 --- a/run-solid-test-suite.sh +++ b/run-solid-test-suite.sh @@ -8,8 +8,8 @@ docker network create testnet docker build -t standalone-solid-server . docker build -t webid-provider https://github.com/pdsinterop/test-suites.git#master:/testers/webid-provider -#docker build -t solid-crud https://github.com/pdsinterop/test-suites.git#master:/testers/solid-crud -docker build --no-cache -t solid-crud https://github.com/pdsinterop/test-suites.git#master:/testers/solid-crud +#docker build -t solid-crud https://github.com/solid/test-suite.git#master:/testers/solid-crud +docker build --no-cache -t solid-crud https://github.com/solid/test-suite.git#master:/testers/solid-crud docker build -t cookie https://github.com/pdsinterop/test-suites.git#master:servers/php-solid-server/cookie docker build -t pubsub-server https://github.com/pdsinterop/php-solid-pubsub-server.git#master From 3c820b2764194bccefe914ae360445c4b0fcf5f8 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Mon, 9 Nov 2020 12:40:54 +0100 Subject: [PATCH 21/25] no caching --- run-solid-test-suite.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-solid-test-suite.sh b/run-solid-test-suite.sh index 5d98799..35ac8b9 100755 --- a/run-solid-test-suite.sh +++ b/run-solid-test-suite.sh @@ -5,7 +5,7 @@ set -e docker network create testnet # Build and start Nextcloud server with code from current repo contents: -docker build -t standalone-solid-server . +docker build --no-cache -t standalone-solid-server . docker build -t webid-provider https://github.com/pdsinterop/test-suites.git#master:/testers/webid-provider #docker build -t solid-crud https://github.com/solid/test-suite.git#master:/testers/solid-crud From 00779764e7bc9fcef53fddf5538ded3391636dd3 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Mon, 9 Nov 2020 15:04:58 +0100 Subject: [PATCH 22/25] cleanup after running --- run-solid-test-suite.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/run-solid-test-suite.sh b/run-solid-test-suite.sh index 35ac8b9..4b11533 100755 --- a/run-solid-test-suite.sh +++ b/run-solid-test-suite.sh @@ -35,7 +35,9 @@ export COOKIE="`docker run --cap-add=SYS_ADMIN --network=testnet --env-file /tmp echo "Running webid-provider tests with cookie $COOKIE" # docker run --rm --network=testnet --env COOKIE="$COOKIE" --env-file /tmp/env-vars-for-test-image.list webid-provider docker run --rm --network=testnet --env-file /tmp/env-vars-for-test-image.list solid-crud -# rm /tmp/env-vars-for-test-image.list -# docker stop standalone-solid-server -# docker rm standalone-solid-server -# docker network remove testnet +rm /tmp/env-vars-for-test-image.list +docker stop server +docker rm server +docker stop pubsub +docker rm pubsub +docker network remove testnet From 13e13e8de5f6ae117920ecee2330e67e909ae7bc Mon Sep 17 00:00:00 2001 From: Michiel de Jong Date: Mon, 9 Nov 2020 15:12:22 +0100 Subject: [PATCH 23/25] Re-enable webid-provider tests --- run-solid-test-suite.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-solid-test-suite.sh b/run-solid-test-suite.sh index 35ac8b9..511c940 100755 --- a/run-solid-test-suite.sh +++ b/run-solid-test-suite.sh @@ -33,7 +33,7 @@ docker logs server echo Getting cookie... export COOKIE="`docker run --cap-add=SYS_ADMIN --network=testnet --env-file /tmp/env-vars-for-test-image.list cookie`" echo "Running webid-provider tests with cookie $COOKIE" -# docker run --rm --network=testnet --env COOKIE="$COOKIE" --env-file /tmp/env-vars-for-test-image.list webid-provider +docker run --rm --network=testnet --env COOKIE="$COOKIE" --env-file /tmp/env-vars-for-test-image.list webid-provider docker run --rm --network=testnet --env-file /tmp/env-vars-for-test-image.list solid-crud # rm /tmp/env-vars-for-test-image.list # docker stop standalone-solid-server From 9ef50d388141cf57cd25f73b7bb6497cc3a63d52 Mon Sep 17 00:00:00 2001 From: Michiel de Jong Date: Mon, 9 Nov 2020 15:21:21 +0100 Subject: [PATCH 24/25] Fix cookie-getter --- run-solid-test-suite.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/run-solid-test-suite.sh b/run-solid-test-suite.sh index 511c940..419cbb8 100755 --- a/run-solid-test-suite.sh +++ b/run-solid-test-suite.sh @@ -10,7 +10,7 @@ docker build --no-cache -t standalone-solid-server . docker build -t webid-provider https://github.com/pdsinterop/test-suites.git#master:/testers/webid-provider #docker build -t solid-crud https://github.com/solid/test-suite.git#master:/testers/solid-crud docker build --no-cache -t solid-crud https://github.com/solid/test-suite.git#master:/testers/solid-crud -docker build -t cookie https://github.com/pdsinterop/test-suites.git#master:servers/php-solid-server/cookie +docker build -t cookie https://github.com/solid/test-suite.git#master:helpers/cookie docker build -t pubsub-server https://github.com/pdsinterop/php-solid-pubsub-server.git#master # wget -O /tmp/env-vars-for-test-image.list https://raw.githubusercontent.com/pdsinterop/test-suites/master/servers/php-solid-server/env.list @@ -31,7 +31,8 @@ docker ps -a docker logs server echo Getting cookie... -export COOKIE="`docker run --cap-add=SYS_ADMIN --network=testnet --env-file /tmp/env-vars-for-test-image.list cookie`" +export COOKIE="`docker run --rm --cap-add=SYS_ADMIN --network=testnet -e SERVER_TYPE=php-solid-server --env-file /tmp/env-vars-for-test-image.list cookie`" + echo "Running webid-provider tests with cookie $COOKIE" docker run --rm --network=testnet --env COOKIE="$COOKIE" --env-file /tmp/env-vars-for-test-image.list webid-provider docker run --rm --network=testnet --env-file /tmp/env-vars-for-test-image.list solid-crud From dee5e803f963473fb620a56c3f64b2b65f63d981 Mon Sep 17 00:00:00 2001 From: Michiel de Jong Date: Mon, 9 Nov 2020 16:44:41 +0100 Subject: [PATCH 25/25] Use own cookie-getter --- run-solid-test-suite.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/run-solid-test-suite.sh b/run-solid-test-suite.sh index 20ab697..48460a9 100755 --- a/run-solid-test-suite.sh +++ b/run-solid-test-suite.sh @@ -10,7 +10,8 @@ docker build --no-cache -t standalone-solid-server . docker build -t webid-provider https://github.com/pdsinterop/test-suites.git#master:/testers/webid-provider #docker build -t solid-crud https://github.com/solid/test-suite.git#master:/testers/solid-crud docker build --no-cache -t solid-crud https://github.com/solid/test-suite.git#master:/testers/solid-crud -docker build -t cookie https://github.com/solid/test-suite.git#master:helpers/cookie +#docker build -t cookie https://github.com/solid/test-suite.git#master:helpers/cookie +docker build -t cookie https://github.com/pdsinterop/test-suites.git#master:servers/php-solid-server/cookie docker build -t pubsub-server https://github.com/pdsinterop/php-solid-pubsub-server.git#master # wget -O /tmp/env-vars-for-test-image.list https://raw.githubusercontent.com/pdsinterop/test-suites/master/servers/php-solid-server/env.list