diff --git a/env-vars-server.list b/env-vars-server.list index 28239ba7..1f38d6fe 100644 --- a/env-vars-server.list +++ b/env-vars-server.list @@ -1,6 +1,6 @@ SERVER_ROOT=https://server -STORAGE_ROOT=https://server/apps/solid/@alice/storage/ -ALICE_WEBID=https://server/apps/solid/@alice/profile/card#me +STORAGE_ROOT=https://server/apps/solid/~alice/storage/ +ALICE_WEBID=https://server/apps/solid/~alice/profile/card#me COOKIE_TYPE=nextcloud-compatible USERNAME=alice PASSWORD=alice123 diff --git a/env-vars-testers.list b/env-vars-testers.list index 366167e0..a8a79563 100644 --- a/env-vars-testers.list +++ b/env-vars-testers.list @@ -1,11 +1,11 @@ -WEBID_ALICE=https://server/apps/solid/@alice/profile/card#me +WEBID_ALICE=https://server/apps/solid/~alice/profile/card#me OIDC_ISSUER_ALICE=https://server -STORAGE_ROOT_ALICE=https://server/apps/solid/@alice/storage/ -WEBID_BOB=https://thirdparty/apps/solid/@alice/profile/card#me +STORAGE_ROOT_ALICE=https://server/apps/solid/~alice/storage/ +WEBID_BOB=https://thirdparty/apps/solid/~alice/profile/card#me OIDC_ISSUER_BOB=https://thirdparty STORAGE_ROOT_BOB=https://thirdparty/ -ALICE_WEBID=https://server/apps/solid/@alice/profile/card#me +ALICE_WEBID=https://server/apps/solid/~alice/profile/card#me SERVER_ROOT_ESCAPED=https:\/\/server SERVER_ROOT=https://server -STORAGE_ROOT=https://server/apps/solid/@alice/storage/ +STORAGE_ROOT=https://server/apps/solid/~alice/storage/ SKIP_CONC=1 diff --git a/env-vars-thirdparty.list b/env-vars-thirdparty.list index 9a2c8416..1c889484 100644 --- a/env-vars-thirdparty.list +++ b/env-vars-thirdparty.list @@ -1,5 +1,5 @@ SERVER_ROOT=https://thirdparty -ALICE_WEBID=https://thirdparty/apps/solid/@alice/profile/card#me +ALICE_WEBID=https://thirdparty/apps/solid/~alice/profile/card#me COOKIE_TYPE=nextcloud-compatible USERNAME=alice PASSWORD=alice123 diff --git a/env.list b/env.list index 1256e61d..cef5c00e 100644 --- a/env.list +++ b/env.list @@ -1,2 +1,2 @@ -ALICE_WEBID=https://server/apps/solid/@alice/profile/card#me +ALICE_WEBID=https://server/apps/solid/~alice/profile/card#me COOKIE_TYPE=nextcloud-compatible diff --git a/solid/appinfo/routes.php b/solid/appinfo/routes.php index 2429ad9f..469902b6 100644 --- a/solid/appinfo/routes.php +++ b/solid/appinfo/routes.php @@ -15,7 +15,6 @@ * it's instantiated in there */ - $routes = [ ['name' => 'page#approval', 'url' => '/sharing/{clientId}', 'verb' => 'GET'], ['name' => 'page#handleRevoke', 'url' => '/revoke/{clientId}', 'verb' => 'DELETE'], @@ -44,33 +43,33 @@ ]; $userIdRoutes = [ - ['name' => 'page#profile', 'url' => '/@{userId}/', 'verb' => 'GET'], - - ['name' => 'profile#handleGet', 'url' => '/@{userId}/profile{path}', 'verb' => 'GET', 'requirements' => ['path' => '.+'], ], - ['name' => 'profile#handlePut', 'url' => '/@{userId}/profile{path}', 'verb' => 'PUT', 'requirements' => ['path' => '.+'], ], - ['name' => 'profile#handlePatch', 'url' => '/@{userId}/profile{path}', 'verb' => 'PATCH', 'requirements' => ['path' => '.+'], ], - ['name' => 'profile#handleHead', 'url' => '/@{userId}/profile{path}', 'verb' => 'HEAD', 'requirements' => ['path' => '.+'], ], - - ['name' => 'storage#handleGet', 'url' => '/@{userId}/storage{path}', 'verb' => 'GET', 'requirements' => ['path' => '.+'], ], - ['name' => 'storage#handlePost', 'url' => '/@{userId}/storage{path}', 'verb' => 'POST', 'requirements' => ['path' => '.+'], ], - ['name' => 'storage#handlePut', 'url' => '/@{userId}/storage{path}', 'verb' => 'PUT', 'requirements' => ['path' => '.+'], ], - ['name' => 'storage#handleDelete', 'url' => '/@{userId}/storage{path}', 'verb' => 'DELETE', 'requirements' => ['path' => '.+'], ], - ['name' => 'storage#handlePatch', 'url' => '/@{userId}/storage{path}', 'verb' => 'PATCH', 'requirements' => ['path' => '.+'], ], - ['name' => 'storage#handleHead', 'url' => '/@{userId}/storage{path}', 'verb' => 'HEAD', 'requirements' => ['path' => '.+'], ], - - ['name' => 'calendar#handleGet', 'url' => '/@{userId}/calendar{path}', 'verb' => 'GET', 'requirements' => ['path' => '.+'], ], - ['name' => 'calendar#handlePost', 'url' => '/@{userId}/calendar{path}', 'verb' => 'POST', 'requirements' => ['path' => '.+'], ], - ['name' => 'calendar#handlePut', 'url' => '/@{userId}/calendar{path}', 'verb' => 'PUT', 'requirements' => ['path' => '.+'], ], - ['name' => 'calendar#handleDelete', 'url' => '/@{userId}/calendar{path}', 'verb' => 'DELETE', 'requirements' => ['path' => '.+'], ], - ['name' => 'calendar#handlePatch', 'url' => '/@{userId}/calendar{path}', 'verb' => 'PATCH', 'requirements' => ['path' => '.+'], ], - ['name' => 'calendar#handleHead', 'url' => '/@{userId}/calendar{path}', 'verb' => 'HEAD', 'requirements' => ['path' => '.+'], ], - - ['name' => 'contacts#handleGet', 'url' => '/@{userId}/contacts{path}', 'verb' => 'GET', 'requirements' => ['path' => '.+'], ], - ['name' => 'contacts#handlePost', 'url' => '/@{userId}/contacts{path}', 'verb' => 'POST', 'requirements' => ['path' => '.+'], ], - ['name' => 'contacts#handlePut', 'url' => '/@{userId}/contacts{path}', 'verb' => 'PUT', 'requirements' => ['path' => '.+'], ], - ['name' => 'contacts#handleDelete', 'url' => '/@{userId}/contacts{path}', 'verb' => 'DELETE', 'requirements' => ['path' => '.+'], ], - ['name' => 'contacts#handlePatch', 'url' => '/@{userId}/contacts{path}', 'verb' => 'PATCH', 'requirements' => ['path' => '.+'], ], - ['name' => 'contacts#handleHead', 'url' => '/@{userId}/contacts{path}', 'verb' => 'HEAD', 'requirements' => ['path' => '.+'], ], + ['name' => 'page#profile', 'url' => '/~{userId}/', 'verb' => 'GET'], + + ['name' => 'profile#handleGet', 'url' => '/~{userId}/profile{path}', 'verb' => 'GET', 'requirements' => ['path' => '.+'], ], + ['name' => 'profile#handlePut', 'url' => '/~{userId}/profile{path}', 'verb' => 'PUT', 'requirements' => ['path' => '.+'], ], + ['name' => 'profile#handlePatch', 'url' => '/~{userId}/profile{path}', 'verb' => 'PATCH', 'requirements' => ['path' => '.+'], ], + ['name' => 'profile#handleHead', 'url' => '/~{userId}/profile{path}', 'verb' => 'HEAD', 'requirements' => ['path' => '.+'], ], + + ['name' => 'storage#handleGet', 'url' => '/~{userId}/storage{path}', 'verb' => 'GET', 'requirements' => ['path' => '.+'], ], + ['name' => 'storage#handlePost', 'url' => '/~{userId}/storage{path}', 'verb' => 'POST', 'requirements' => ['path' => '.+'], ], + ['name' => 'storage#handlePut', 'url' => '/~{userId}/storage{path}', 'verb' => 'PUT', 'requirements' => ['path' => '.+'], ], + ['name' => 'storage#handleDelete', 'url' => '/~{userId}/storage{path}', 'verb' => 'DELETE', 'requirements' => ['path' => '.+'], ], + ['name' => 'storage#handlePatch', 'url' => '/~{userId}/storage{path}', 'verb' => 'PATCH', 'requirements' => ['path' => '.+'], ], + ['name' => 'storage#handleHead', 'url' => '/~{userId}/storage{path}', 'verb' => 'HEAD', 'requirements' => ['path' => '.+'], ], + + ['name' => 'calendar#handleGet', 'url' => '/~{userId}/calendar{path}', 'verb' => 'GET', 'requirements' => ['path' => '.+'], ], + ['name' => 'calendar#handlePost', 'url' => '/~{userId}/calendar{path}', 'verb' => 'POST', 'requirements' => ['path' => '.+'], ], + ['name' => 'calendar#handlePut', 'url' => '/~{userId}/calendar{path}', 'verb' => 'PUT', 'requirements' => ['path' => '.+'], ], + ['name' => 'calendar#handleDelete', 'url' => '/~{userId}/calendar{path}', 'verb' => 'DELETE', 'requirements' => ['path' => '.+'], ], + ['name' => 'calendar#handlePatch', 'url' => '/~{userId}/calendar{path}', 'verb' => 'PATCH', 'requirements' => ['path' => '.+'], ], + ['name' => 'calendar#handleHead', 'url' => '/~{userId}/calendar{path}', 'verb' => 'HEAD', 'requirements' => ['path' => '.+'], ], + + ['name' => 'contacts#handleGet', 'url' => '/~{userId}/contacts{path}', 'verb' => 'GET', 'requirements' => ['path' => '.+'], ], + ['name' => 'contacts#handlePost', 'url' => '/~{userId}/contacts{path}', 'verb' => 'POST', 'requirements' => ['path' => '.+'], ], + ['name' => 'contacts#handlePut', 'url' => '/~{userId}/contacts{path}', 'verb' => 'PUT', 'requirements' => ['path' => '.+'], ], + ['name' => 'contacts#handleDelete', 'url' => '/~{userId}/contacts{path}', 'verb' => 'DELETE', 'requirements' => ['path' => '.+'], ], + ['name' => 'contacts#handlePatch', 'url' => '/~{userId}/contacts{path}', 'verb' => 'PATCH', 'requirements' => ['path' => '.+'], ], + ['name' => 'contacts#handleHead', 'url' => '/~{userId}/contacts{path}', 'verb' => 'HEAD', 'requirements' => ['path' => '.+'], ], ]; // @TODO: All routes NOT generated by the UrlGenerator ANYWHERE in the code need to be checked! @@ -78,13 +77,13 @@ if (Application::$userSubDomainsEnabled) { $userIdRoutes = array_map(function ($route) { if ($route['name'] === 'page#profile') { - // The profile route should be `/me` instead of `/@{userId}/` + // The profile route should be `/me` instead of `/~{userId}/` $route['url'] = '/me'; } else { // When UserSubDomains are enabled, all routes that start with - // `/@{userId}/` should just be `/`, as the userId is present + // `/~{userId}/` should just be `/`, as the userId is present // in the subdomain. - $route['url'] = preg_replace('#^/@{userId}/#', '/', $route['url']); + $route['url'] = preg_replace('#^/~{userId}/#', '/', $route['url']); } // The required userId is set to the userId from the subdomain diff --git a/solid/composer.json b/solid/composer.json index 61dbb3b6..b49ad6ae 100644 --- a/solid/composer.json +++ b/solid/composer.json @@ -30,9 +30,9 @@ "laminas/laminas-diactoros": "^2.8", "lcobucci/jwt": "^4.1", "pdsinterop/flysystem-nextcloud": "^0.2", - "pdsinterop/flysystem-rdf": "^0.5", - "pdsinterop/solid-auth": "v0.11.0", - "pdsinterop/solid-crud": "^0.7.3", + "pdsinterop/flysystem-rdf": "^0.6", + "pdsinterop/solid-auth": "^0.12.2", + "pdsinterop/solid-crud": "^0.8", "psr/log": "^1.1" }, "require-dev": { diff --git a/solid/composer.lock b/solid/composer.lock index 40fd3303..026aa830 100644 --- a/solid/composer.lock +++ b/solid/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1843d50801f15c12e9fb50345b3bfb3b", + "content-hash": "630d8401030511a28cf54157d9bbd4cf", "packages": [ { "name": "arc/base", @@ -1455,24 +1455,24 @@ }, { "name": "pdsinterop/flysystem-rdf", - "version": "v0.5.0", + "version": "v0.6.0", "source": { "type": "git", "url": "https://github.com/pdsinterop/flysystem-rdf.git", - "reference": "2a0b105f66c16b664bcd56f30d76f464b18be065" + "reference": "cb72c2a0538b2a552a9281f2bd9e4a7f48ca035d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pdsinterop/flysystem-rdf/zipball/2a0b105f66c16b664bcd56f30d76f464b18be065", - "reference": "2a0b105f66c16b664bcd56f30d76f464b18be065", + "url": "https://api.github.com/repos/pdsinterop/flysystem-rdf/zipball/cb72c2a0538b2a552a9281f2bd9e4a7f48ca035d", + "reference": "cb72c2a0538b2a552a9281f2bd9e4a7f48ca035d", "shasum": "" }, "require": { - "easyrdf/easyrdf": "^1.1.1", "ext-mbstring": "*", "league/flysystem": "^1.0", "ml/json-ld": "^1.2", - "php": "^8.0" + "php": "^8.0", + "sweetrdf/easyrdf": "^1.1" }, "require-dev": { "phpunit/phpunit": "^8|^9" @@ -1490,22 +1490,22 @@ "description": "Flysystem plugin to transform RDF data between various serialization formats.", "support": { "issues": "https://github.com/pdsinterop/flysystem-rdf/issues", - "source": "https://github.com/pdsinterop/flysystem-rdf/tree/v0.5.0" + "source": "https://github.com/pdsinterop/flysystem-rdf/tree/v0.6.0" }, - "time": "2022-08-22T14:36:29+00:00" + "time": "2025-05-16T08:57:11+00:00" }, { "name": "pdsinterop/solid-auth", - "version": "v0.11.0", + "version": "v0.12.2", "source": { "type": "git", "url": "https://github.com/pdsinterop/php-solid-auth.git", - "reference": "0c5f65b0a9340fe9d50bef9d0e279db54610ffac" + "reference": "1d1160ee0f7ca71d3e34151aea94232e1cfa49ff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pdsinterop/php-solid-auth/zipball/0c5f65b0a9340fe9d50bef9d0e279db54610ffac", - "reference": "0c5f65b0a9340fe9d50bef9d0e279db54610ffac", + "url": "https://api.github.com/repos/pdsinterop/php-solid-auth/zipball/1d1160ee0f7ca71d3e34151aea94232e1cfa49ff", + "reference": "1d1160ee0f7ca71d3e34151aea94232e1cfa49ff", "shasum": "" }, "require": { @@ -1514,7 +1514,7 @@ "ext-openssl": "*", "laminas/laminas-diactoros": "^2.8", "lcobucci/jwt": "^4.1", - "league/oauth2-server": "^8.3.5", + "league/oauth2-server": "^8.5.5", "php": "^8.0", "web-token/jwt-core": "^2.2" }, @@ -1539,22 +1539,22 @@ "description": "OAuth2, OpenID and OIDC for Solid Server implementations.", "support": { "issues": "https://github.com/pdsinterop/php-solid-auth/issues", - "source": "https://github.com/pdsinterop/php-solid-auth/tree/v0.11.0" + "source": "https://github.com/pdsinterop/php-solid-auth/tree/v0.12.2" }, - "time": "2025-02-14T12:57:21+00:00" + "time": "2025-05-28T14:53:41+00:00" }, { "name": "pdsinterop/solid-crud", - "version": "v0.7.3", + "version": "v0.8.0", "source": { "type": "git", "url": "https://github.com/pdsinterop/php-solid-crud.git", - "reference": "c5369ef7b46d3d77a7686c3f4531e818e1797e27" + "reference": "ca1421770b17c69cc5989ce6864e86405030a50c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pdsinterop/php-solid-crud/zipball/c5369ef7b46d3d77a7686c3f4531e818e1797e27", - "reference": "c5369ef7b46d3d77a7686c3f4531e818e1797e27", + "url": "https://api.github.com/repos/pdsinterop/php-solid-crud/zipball/ca1421770b17c69cc5989ce6864e86405030a50c", + "reference": "ca1421770b17c69cc5989ce6864e86405030a50c", "shasum": "" }, "require": { @@ -1562,7 +1562,7 @@ "laminas/laminas-diactoros": "^2.14", "league/flysystem": "^1.0", "mjrider/flysystem-factory": "^0.7", - "pdsinterop/flysystem-rdf": "^0.5", + "pdsinterop/flysystem-rdf": "^0.6", "php": "^8.0", "pietercolpaert/hardf": "^0.3", "psr/http-factory": "^1.0", @@ -1586,9 +1586,9 @@ "description": "Solid HTTPS REST API specification compliant implementation for handling Resource CRUD", "support": { "issues": "https://github.com/pdsinterop/php-solid-crud/issues", - "source": "https://github.com/pdsinterop/php-solid-crud/tree/v0.7.3" + "source": "https://github.com/pdsinterop/php-solid-crud/tree/v0.8.0" }, - "time": "2024-01-17T10:48:57+00:00" + "time": "2025-05-16T09:04:57+00:00" }, { "name": "phrity/net-uri", @@ -2128,6 +2128,82 @@ ], "time": "2020-11-03T09:10:25+00:00" }, + { + "name": "sweetrdf/easyrdf", + "version": "1.7", + "source": { + "type": "git", + "url": "https://github.com/sweetrdf/easyrdf.git", + "reference": "6952b79bd1818817f20d0c64de54c7ecd5a24947" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sweetrdf/easyrdf/zipball/6952b79bd1818817f20d0c64de54c7ecd5a24947", + "reference": "6952b79bd1818817f20d0c64de54c7ecd5a24947", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-mbstring": "*", + "ext-pcre": "*", + "ext-xmlreader": "*", + "lib-libxml": "*", + "php": "^7.1|^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.0", + "ml/json-ld": "^1.0", + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^7.5|^8.5|^9.5", + "semsol/arc2": "^2.4", + "zendframework/zend-http": "^2.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "EasyRdf\\": "lib" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nicholas Humfrey", + "email": "njh@aelius.com", + "homepage": "http://www.aelius.com/njh/", + "role": "Developer" + }, + { + "name": "Alexey Zakhlestin", + "email": "indeyets@gmail.com", + "homepage": "http://indeyets.ru/", + "role": "Developer" + }, + { + "name": "Konrad Abicht", + "email": "hi@inspirito.de", + "homepage": "http://inspirito.de/", + "role": "Maintainer, Developer" + } + ], + "description": "EasyRdf is a PHP library designed to make it easy to consume and produce RDF.", + "keywords": [ + "Linked Data", + "RDF", + "Semantic Web", + "Turtle", + "rdfa", + "sparql" + ], + "support": { + "issues": "https://github.com/sweetrdf/easyrdf/issues", + "source": "https://github.com/sweetrdf/easyrdf/tree/1.7" + }, + "time": "2022-09-19T07:53:57+00:00" + }, { "name": "textalk/websocket", "version": "1.6.3", diff --git a/solid/lib/Controller/CalendarController.php b/solid/lib/Controller/CalendarController.php index 046cef08..9030dabb 100644 --- a/solid/lib/Controller/CalendarController.php +++ b/solid/lib/Controller/CalendarController.php @@ -185,31 +185,31 @@ public function handlePost($userId, $path) { * @NoAdminRequired * @NoCSRFRequired */ - public function handlePut() { // $userId, $path) { - // FIXME: Adding the correct variables in the function name will make nextcloud - // throw an error about accessing put twice, so we will find out the userId and path from $_SERVER instead; + public function handlePut() { // $userId, $path) { + // FIXME: Adding the correct variables in the function name will make nextcloud + // throw an error about accessing put twice, so we will find out the userId and path from $_SERVER instead; - // because we got here, the request uri should look like: - // - if we have user subdomains enabled: - // /index.php/apps/solid/calendar{path} - // and otherwise: - // index.php/apps/solid/~{userId}/calendar{path} + // because we got here, the request uri should look like: + // - if we have user subdomains enabled: + // /index.php/apps/solid/calendar{path} + // and otherwise: + // index.php/apps/solid/~{userId}/calendar{path} // In the first case, we'll get the username from the SERVER_NAME. In the latter, it will come from the URL; - if ($this->config->getUserSubDomainsEnabled()) { - $pathInfo = explode("calendar/", $_SERVER['REQUEST_URI']); - $path = $pathInfo[1]; - $userId = explode(".", $_SERVER['SERVER_NAME'])[0]; - } else { - $pathInfo = explode("~", $_SERVER['REQUEST_URI']); - $pathInfo = explode("/", $pathInfo[1], 2); - $userId = $pathInfo[0]; - $path = $pathInfo[1]; - $path = preg_replace("/^calendar/", "", $path); - } - - return $this->handleRequest($userId, $path); - } + if ($this->config->getUserSubDomainsEnabled()) { + $pathInfo = explode("calendar/", $_SERVER['REQUEST_URI']); + $path = $pathInfo[1]; + $userId = explode(".", $_SERVER['SERVER_NAME'])[0]; + } else { + $pathInfo = explode("~", $_SERVER['REQUEST_URI']); + $pathInfo = explode("/", $pathInfo[1], 2); + $userId = $pathInfo[0]; + $path = $pathInfo[1]; + $path = preg_replace("/^calendar/", "", $path); + } + + return $this->handleRequest($userId, $path); + } /** * @PublicPage * @NoAdminRequired diff --git a/solid/lib/Controller/ContactsController.php b/solid/lib/Controller/ContactsController.php index 3d2f52bb..0363add2 100644 --- a/solid/lib/Controller/ContactsController.php +++ b/solid/lib/Controller/ContactsController.php @@ -186,31 +186,31 @@ public function handlePost($userId, $path) { * @NoAdminRequired * @NoCSRFRequired */ - public function handlePut() { // $userId, $path) { - // FIXME: Adding the correct variables in the function name will make nextcloud - // throw an error about accessing put twice, so we will find out the userId and path from $_SERVER instead; + public function handlePut() { // $userId, $path) { + // FIXME: Adding the correct variables in the function name will make nextcloud + // throw an error about accessing put twice, so we will find out the userId and path from $_SERVER instead; - // because we got here, the request uri should look like: - // - if we have user subdomains enabled: - // /index.php/apps/solid/contacts{path} - // and otherwise: - // index.php/apps/solid/~{userId}/contacts{path} + // because we got here, the request uri should look like: + // - if we have user subdomains enabled: + // /index.php/apps/solid/contacts{path} + // and otherwise: + // index.php/apps/solid/~{userId}/contacts{path} // In the first case, we'll get the username from the SERVER_NAME. In the latter, it will come from the URL; - if ($this->config->getUserSubDomainsEnabled()) { - $pathInfo = explode("contacts/", $_SERVER['REQUEST_URI']); - $path = $pathInfo[1]; - $userId = explode(".", $_SERVER['SERVER_NAME'])[0]; - } else { - $pathInfo = explode("~", $_SERVER['REQUEST_URI']); - $pathInfo = explode("/", $pathInfo[1], 2); - $userId = $pathInfo[0]; - $path = $pathInfo[1]; - $path = preg_replace("/^contacts/", "", $path); - } - - return $this->handleRequest($userId, $path); - } + if ($this->config->getUserSubDomainsEnabled()) { + $pathInfo = explode("contacts/", $_SERVER['REQUEST_URI']); + $path = $pathInfo[1]; + $userId = explode(".", $_SERVER['SERVER_NAME'])[0]; + } else { + $pathInfo = explode("~", $_SERVER['REQUEST_URI']); + $pathInfo = explode("/", $pathInfo[1], 2); + $userId = $pathInfo[0]; + $path = $pathInfo[1]; + $path = preg_replace("/^contacts/", "", $path); + } + + return $this->handleRequest($userId, $path); + } /** * @PublicPage * @NoAdminRequired diff --git a/solid/lib/Controller/ProfileController.php b/solid/lib/Controller/ProfileController.php index 24560dc7..66391438 100644 --- a/solid/lib/Controller/ProfileController.php +++ b/solid/lib/Controller/ProfileController.php @@ -204,31 +204,30 @@ public function handlePost($userId, $path) { * @NoAdminRequired * @NoCSRFRequired */ - public function handlePut() { // $userId, $path) { - // FIXME: Adding the correct variables in the function name will make nextcloud - // throw an error about accessing put twice, so we will find out the userId and path from $_SERVER instead; - - // because we got here, the request uri should look like: - // - if we have user subdomains enabled: - // /index.php/apps/solid/profile{path} - // and otherwise: - // index.php/apps/solid/~{userId}/profile{path} - + public function handlePut() { // $userId, $path) { + // FIXME: Adding the correct variables in the function name will make nextcloud + // throw an error about accessing put twice, so we will find out the userId and path from $_SERVER instead; + + // because we got here, the request uri should look like: + // - if we have user subdomains enabled: + // /index.php/apps/solid/profile{path} + // and otherwise: + // index.php/apps/solid/~{userId}/profile{path} // In the first case, we'll get the username from the SERVER_NAME. In the latter, it will come from the URL; - if ($this->config->getUserSubDomainsEnabled()) { - $pathInfo = explode("profile/", $_SERVER['REQUEST_URI']); - $path = $pathInfo[1]; - $userId = explode(".", $_SERVER['SERVER_NAME'])[0]; - } else { - $pathInfo = explode("~", $_SERVER['REQUEST_URI']); - $pathInfo = explode("/", $pathInfo[1], 2); - $userId = $pathInfo[0]; - $path = $pathInfo[1]; - $path = preg_replace("/^profile/", "", $path); - } - - return $this->handleRequest($userId, $path); - } + if ($this->config->getUserSubDomainsEnabled()) { + $pathInfo = explode("profile/", $_SERVER['REQUEST_URI']); + $path = $pathInfo[1]; + $userId = explode(".", $_SERVER['SERVER_NAME'])[0]; + } else { + $pathInfo = explode("~", $_SERVER['REQUEST_URI']); + $pathInfo = explode("/", $pathInfo[1], 2); + $userId = $pathInfo[0]; + $path = $pathInfo[1]; + $path = preg_replace("/^profile/", "", $path); + } + + return $this->handleRequest($userId, $path); + } /** * @PublicPage * @NoAdminRequired diff --git a/solid/lib/Controller/SolidWebhookController.php b/solid/lib/Controller/SolidWebhookController.php index 371e3c02..5846097d 100644 --- a/solid/lib/Controller/SolidWebhookController.php +++ b/solid/lib/Controller/SolidWebhookController.php @@ -150,13 +150,13 @@ private function initializeStorage($userId) { } private function parseTopic($topic) { - // topic = https://nextcloud.server/solid/@alice/storage/foo/bar + // topic = https://nextcloud.server/solid/~alice/storage/foo/bar $appBaseUrl = $this->getAppBaseUrl(); // https://nextcloud.server/solid/ - $internalUrl = str_replace($appBaseUrl, '', $topic); // @alice/storage/foo/bar + $internalUrl = str_replace($appBaseUrl, '', $topic); // ~alice/storage/foo/bar $pathicles = explode("/", $internalUrl); - $userId = $pathicles[0]; // @alice - $userId = preg_replace("/^@/", "", $userId); // alice - $storageUrl = $this->getStorageUrl($userId); // https://nextcloud.server/solid/@alice/storage/ + $userId = $pathicles[0]; // ~alice + $userId = preg_replace("/^~/", "", $userId); // alice + $storageUrl = $this->getStorageUrl($userId); // https://nextcloud.server/solid/~alice/storage/ $storagePath = str_replace($storageUrl, '/', $topic); // /foo/bar return array( "userId" => $userId, @@ -182,7 +182,7 @@ private function createGetRequest($topic) { } private function checkReadAccess($topic) { - // split out $topic into $userId and $path https://nextcloud.server/solid/@alice/storage/foo/bar + // split out $topic into $userId and $path https://nextcloud.server/solid/~alice/storage/foo/bar // - userId in this case is the pod owner (not the one doing the request). (alice) // - path is the path within the storage pod (/foo/bar) $target = $this->parseTopic($topic); diff --git a/solid/lib/Controller/StorageController.php b/solid/lib/Controller/StorageController.php index de4cd201..4a834d3b 100644 --- a/solid/lib/Controller/StorageController.php +++ b/solid/lib/Controller/StorageController.php @@ -375,31 +375,30 @@ public function handlePost($userId, $path) { * @NoAdminRequired * @NoCSRFRequired */ - public function handlePut() { // $userId, $path) { - // FIXME: Adding the correct variables in the function name will make nextcloud - // throw an error about accessing put twice, so we will find out the userId and path from $_SERVER instead; - - // because we got here, the request uri should look like: - // - if we have user subdomains enabled: - // /index.php/apps/solid/storage{path} - // and otherwise: - // index.php/apps/solid/~{userId}/storage{path} - + public function handlePut() { // $userId, $path) { + // FIXME: Adding the correct variables in the function name will make nextcloud + // throw an error about accessing put twice, so we will find out the userId and path from $_SERVER instead; + + // because we got here, the request uri should look like: + // - if we have user subdomains enabled: + // /index.php/apps/solid/storage{path} + // and otherwise: + // index.php/apps/solid/~{userId}/storage{path} // In the first case, we'll get the username from the SERVER_NAME. In the latter, it will come from the URL; - if ($this->config->getUserSubDomainsEnabled()) { - $pathInfo = explode("storage/", $_SERVER['REQUEST_URI']); - $path = $pathInfo[1]; - $userId = explode(".", $_SERVER['SERVER_NAME'])[0]; - } else { - $pathInfo = explode("~", $_SERVER['REQUEST_URI']); - $pathInfo = explode("/", $pathInfo[1], 2); - $userId = $pathInfo[0]; - $path = $pathInfo[1]; - $path = preg_replace("/^storage/", "", $path); - } - - return $this->handleRequest($userId, $path); - } + if ($this->config->getUserSubDomainsEnabled()) { + $pathInfo = explode("storage/", $_SERVER['REQUEST_URI']); + $path = $pathInfo[1]; + $userId = explode(".", $_SERVER['SERVER_NAME'])[0]; + } else { + $pathInfo = explode("~", $_SERVER['REQUEST_URI']); + $pathInfo = explode("/", $pathInfo[1], 2); + $userId = $pathInfo[0]; + $path = $pathInfo[1]; + $path = preg_replace("/^storage/", "", $path); + } + + return $this->handleRequest($userId, $path); + } /** * @PublicPage * @NoAdminRequired