pdsinterop / php-solid-server

Standalone Solid Server written in PHP by PDS Interop
https://pdsinterop.org/php-solid-server/
MIT License
46 stars 7 forks source link

Feedback using in development with a Solid App in the browser #42

Open NoelDeMartin opened 3 years ago

NoelDeMartin commented 3 years ago

I've been tinkering with the server to make my apps compatible, and I wasn't able to make it work out of the box but I'll share what I got working. I know many of the things I'll mention are known bugs or missing features, we can reference them or open new issues, and close this one afterwards.

I tested the server using this app: noeldemartin/ramen. You can use it in your local environment if you want to reproduce the problems I'll mention.

So here's what I did.

First I launched PSS by cloning this repo and running the following command:

export PORT=8000 &&      \
docker run               \
    --env "PORT=${PORT}" \
    --expose "${PORT}"   \
    --network host       \
    --rm                 \
    --volume "$PWD:/app" \
    --workdir /app/      \
    -it                  \
    php:7.3              \
    sh -l

Inside the docker container shell, I installed composer and git and then I run composer install and composer serve-dev (keep in mind that I had some modifications that I've added in this PR).

Once this was up and running, I started encountering some problems that I hot-fixed along the way. None of them are actual fixes, more like hard-coding things to work in my environment. That's why I won't open a PR with that, but I'll explain what those are:

  1. Multiple CORS errors. I think this is already a known problem because I've seen a TODO mentioning it.
  2. DPoP JWK validation failed, inside of pdsinterop/solid-auth. First this failed because the $alg variable was "ES256" (instead of "RS256"), and then here I got an exception saying "This JWK cannot be converted to PEM format".
  3. Websocket notifications failed, inside of pdsinterop/solid-crud. In this line, I got an exception saying "Connection to 'ws://localhost/' failed: Server sent invalid upgrade".
  4. In authenticated requests, I got an error saying "Invalid token". This is probably because I commented out a lot of the errors I've mentioned in the 2nd point.
  5. When I created a container, it was actually created like a turtle file, not a folder. After manually creating a folder it works for the most part, but I wasn't able to add properties to the container in a .meta document.
  6. Using PATCH in an existing document returns an error. I think this is because I was using <> and there's a FIXME mentioning that it isn't supported.
  7. Using PATCH to create a new document works but the document is empty. I think this is because in the PATCH body I am refering the document as http://localhost:8008/storage/container/document#it but after writing the contents of the document manually they are returned as https://localhost/storage/container/container#it instead. Notice that it's using https:// and doesn't include the port, I'm not sure if this is something I didn't configure correctly or a bug, but I was using the server with http:// and the port from the browser.

And that's how far I got, after doing some of the fixes I mentioned my app is able to log in and read the documents :D. Containers and files are created, but I had to make some manual fixes as I've mentioned.

If you don't want or can't run my app, here's a summary of what it's doing (with simplified requests):

  1. Logs in using @inrupt/solid-authn-client-browser.

  2. Reads the profile to get pim:storage and solid:privateTypeIndex.

  3. Finds a container of schema:Recipe declared in the type index and a recipe with "ramen" in the title.

  4. If the container does not exist, users can create it triggering a request similar to this:

    curl 'http://localhost:8000/storage/' -i \ # obtained from pim:storage
      -H 'Slug: my-container' \
      -H 'Content-Type: text/turtle' \
      -H 'Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel="type"' \
      --data '<> <http://www.w3.org/2000/01/rdf-schema#label> "My Container" .'

    And then the type index is updated like this:

    curl 'http://localhost:8000/storage/settings/privateTypeIndex.ttl' -X PATCH \ # obtained from solid:privateTypeIndex
       -H 'Content-Type: application/sparql-update'  \
       --data-raw $'INSERT DATA { <http://localhost:8000/storage/settings/privateTypeIndex.ttl#9507329f-a9a5-4e56-8b13-ee83cfe5fdc3> a <http://www.w3.org/ns/solid/terms#TypeRegistration> .\n<http://localhost:8000/storage/settings/privateTypeIndex.ttl#9507329f-a9a5-4e56-8b13-ee83cfe5fdc3> <http://www.w3.org/ns/solid/terms#forClass> <https://schema.org/Recipe> .\n<http://localhost:8000/storage/settings/privateTypeIndex.ttl#9507329f-a9a5-4e56-8b13-ee83cfe5fdc3> <http://www.w3.org/ns/solid/terms#instanceContainer> <http://localhost:8000/storage/container/> . }'
  5. If the recipe does not exist, users can create it triggering a request similar to this:

    curl 'http://localhost:8000/storage/container/document' -X PATCH \
      -H 'Content-Type: application/sparql-update' \
      --data-raw $'INSERT DATA { <http://localhost:8000/storage/container/document#it> a <https://schema.org/Recipe> . }'

I hope this is helpful! And thanks for working on this, it's great to see a php Solid server :).

As I mentioned, once these problems are tracked elsewhere I think we can close this one. There's also some things I may be doing wrong on my part, let me know if something doesn't look right.

Potherca commented 3 years ago

First of all, allow me to offer you a very big "thank you"!

We've been discussing compatibility with other apps and real-world workings, especially since no new features need to be added to this Standalone PHP version, so coming iterations are all about getting things to work properly across the board.

This is awesome work. We've been scrambling to get things done over the last couple of months and there are still a lot of loose ends we need to tie up. Your contribution here is a great help for that!