Skip to content

Commit 622294f

Browse files
authored
Merge pull request #2 from potherca-contrib/feature/second-draft
Second draft: Hard-coded profile card
2 parents d1b7384 + b3e5db0 commit 622294f

16 files changed

+618
-84
lines changed

CODE_OF_CONDUCT.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
---
2-
title: Code of Conduct
3-
permalink: /code-of-conduct/
4-
---
5-
61
# Contributor Code of Conduct
72

8-
All PDS Interop projects adhere to both [the Code Manifesto](http://codemanifesto.com) and [the Contributor Covenant](http://contributor-covenant.org)
3+
All PDS Interop projects adhere to [the Code Manifesto](http://codemanifesto.com)
94
as its guidelines for contributor and community interactions.
105

11-
126
For full details visit: [https://pdsinterop.org/code-of-conduct/](https://pdsinterop.org/code-of-conduct/)

CONTRIBUTING.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
---
2-
title: Contributing
3-
permalink: /contributing/
4-
---
5-
61
# Contributing to the PHP standalone Solid Server
72

83
Thank you for your interest in contributing!

README.md

Lines changed: 74 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
# Standalone PHP Solid Server
22

3-
> Standalone Solid Server written in PHP by PDS Interop
3+
[![PDS Interop][pdsinterop-shield]][pdsinterop-site]
4+
[![Project stage: Development][project-stage-badge: Development]][project-stage-page]
5+
[![License][license-shield]][license-link]
6+
[![Latest Version][version-shield]][version-link]
7+
[![standard-readme compliant][standard-readme-shield]][standard-readme-link]
8+
![Maintained][maintained-shield]
49

5-
## Solid Server
10+
_Standalone Solid Server written in PHP by PDS Interop_
11+
12+
## Table of Contents
13+
14+
<!-- toc -->
15+
<!-- tocstop -->
16+
17+
## Background
618

719
The Solid specifications defines what makes a "Solid Server". Parts of
820
those specifications are still likely to change, but at the time of this writing,
@@ -20,29 +32,6 @@ they define:
2032
To read more about Solid, and which IETF and W3C specifications are used, visit: https://pdsinterop.org/solid-specs-overview/
2133
-->
2234

23-
## Available Features
24-
25-
Based on the specifications, the following features are available:
26-
27-
1. User
28-
- [ ] Authentication
29-
- [ ] Identity
30-
- [ ] Profiles
31-
2. Data storage
32-
- [ ] Content representation
33-
- [ ] Resource API
34-
- [ ] HTTP REST API
35-
- [ ] Websocket API
36-
3. Web Acces Control List
37-
- [ ] Authorization (and Access Control)
38-
4. Social web apps
39-
- [ ] Calendar
40-
- [ ] Contacts
41-
- [ ] Friends Lists (Followers, Following)
42-
- [ ] Notifications
43-
44-
The checkboxes show which features are available, and which ones are not.
45-
4635
### Installation
4736

4837
To install the project, clone it from GitHub and install the PHP dependencies
@@ -59,29 +48,21 @@ At this point, the application is ready to run.
5948

6049
The PHP Solid server can be run in several different ways.
6150

62-
<!-- @TODO: Add local Dockerfile
51+
<!-- @TODO: Add local Dockerfile -->
6352

64-
The easiest is using the provided `Dockerfile`.
65-
66-
If a different environment is desired, the application can be run with the
67-
Docker image of your choice.
53+
The application can be run with a Docker image of your choice or on a local
54+
environment, using Apache, NginX, or PHP's internal HTTP server. The latter is
55+
only advised in development.
6856

69-
Lastly, the application can be run on a local environment, using Apache, NginX,
70-
or PHP's internal HTTP server. The latter is only advised in development.
71-
-->
57+
For security reasons, the server expects to run on HTTPS (also known as HTTP+TLS).
7258

73-
The application can be run with a Docker image of your choice or on a local environment, using Apache, NginX, or PHP's internal HTTP server. The latter is
74-
only advised in development.
59+
To run insecure, set the environment variable `ENVIRONMENT` to `develop`. This
60+
will prohibit the application from running in production mode.
7561

7662
<!--
7763
@TODO: Add single-button deploy scripts/config for Heroku, Glitch, and other
7864
popular playgrounds/developer oriented service providers.
7965
-->
80-
<!--
81-
### Provided Dockerfile
82-
83-
In the project root, run: `docker run`
84-
-->
8566

8667
### Docker images
8768

@@ -91,7 +72,7 @@ to wherever it will be hosted by the Docker container.
9172
For instance:
9273

9374
```
94-
export PORT=80 && \
75+
export PORT=8080 && \
9576
docker run \
9677
--env "PORT=${PORT}" \
9778
--expose "${PORT}" \
@@ -100,7 +81,7 @@ docker run \
10081
--volume "$PWD:/app" \
10182
-it \
10283
php:7.1 \
103-
php -S "localhost:${PORT}" -t /app/web/ /app/web/index.php
84+
php --docroot /app/web/ --server "localhost:${PORT}" /app/web/index.php
10485
```
10586

10687
### Local environment
@@ -151,18 +132,29 @@ If you discover any security related issues, please email <[email protected]
151132
152133
-->
153134

154-
## Contributing
155-
156-
Contributions are welcomed. Read the [contribution guidelines](CONTRIBUTING.md) for
157-
details.
135+
## Available Features
158136

159-
## Change Log
137+
Based on the specifications, the following features are available:
160138

161-
Please see [CHANGELOG](CHANGELOG.md) for details.
139+
1. User
140+
- [ ] Authentication
141+
- [ ] Identity
142+
- [ ] Profiles
143+
2. Data storage
144+
- [ ] Content representation
145+
- [ ] Resource API
146+
- [ ] HTTP REST API
147+
- [ ] Websocket API
148+
3. Web Acces Control List
149+
- [ ] Authorization (and Access Control)
150+
4. Social web apps
151+
- [ ] Calendar
152+
- [ ] Contacts
153+
- [ ] Friends Lists (Followers, Following)
154+
- [ ] Notifications
162155

163-
## License
156+
The checkboxes show which features are available, and which ones are not.
164157

165-
All code created by PDS Interop is licensed under the [MIT License][LICENSE].
166158

167159
## Development
168160

@@ -210,3 +202,35 @@ The PHPUnit version to be used is the one installed as a `dev-` dependency via c
210202
$ ./vendor/bin/phpunit
211203
```
212204
-->
205+
206+
## Contributing
207+
208+
Questions or feedback can be given by [opening an issue on GitHub](https://github.com/pdsinterop/flysystem-rdf/issues).
209+
210+
All PDS Interop projects are open source and community-friendly.
211+
Any contribution is welcome!
212+
For more details read the [contribution guidelines](contributing.md).
213+
214+
All PDS Interop projects adhere to [the Code Manifesto](http://codemanifesto.com)
215+
as its [code-of-conduct](CODE_OF_CONDUCT.md). Contributors are expected to abide by its terms.
216+
217+
There is [a list of all contributors on GitHub][contributors-page].
218+
219+
For a list of changes see the [CHANGELOG](CHANGELOG.md) or the GitHub releases page.
220+
221+
## License
222+
223+
All code created by PDS Interop is licensed under the [MIT License][license-link].
224+
225+
[contributors-page]: https://github.com/pdsinterop/flysystem-rdf/contributors
226+
[license-link]: ./LICENSE
227+
[license-shield]: https://img.shields.io/github/license/pdsinterop/flysystem-rdf.svg
228+
[maintained-shield]: https://img.shields.io/maintenance/yes/2020
229+
[pdsinterop-shield]: https://img.shields.io/badge/-PDS%20Interop-gray.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9Ii01IC01IDExMCAxMTAiIGZpbGw9IiNGRkYiIHN0cm9rZS13aWR0aD0iMCI+CiAgICA8cGF0aCBkPSJNLTEgNTJoMTdhMzcuNSAzNC41IDAgMDAyNS41IDMxLjE1di0xMy43NWEyMC43NSAyMSAwIDAxOC41LTQwLjI1IDIwLjc1IDIxIDAgMDE4LjUgNDAuMjV2MTMuNzVhMzcgMzQuNSAwIDAwMjUuNS0zMS4xNWgxN2EyMiAyMS4xNSAwIDAxLTEwMiAweiIvPgogICAgPHBhdGggZD0iTSAxMDEgNDhhMi43NyAyLjY3IDAgMDAtMTAyIDBoIDE3YTIuOTcgMi44IDAgMDE2OCAweiIvPgo8L3N2Zz4K
230+
[pdsinterop-site]: https://pdsinterop.org/
231+
[project-stage-badge: Development]: https://img.shields.io/badge/Project%20Stage-Development-yellowgreen.svg
232+
[project-stage-page]: https://blog.pother.ca/project-stages/
233+
[standard-readme-link]: https://github.com/RichardLitt/standard-readme
234+
[standard-readme-shield]: https://img.shields.io/badge/readme%20style-standard-brightgreen.svg
235+
[version-link]: https://packagist.org/packages/pdsinterop/flysystem-rdf
236+
[version-shield]: https://img.shields.io/github/v/release/pdsinterop/flysystem-rdf?sort=semver

bin/serve-docker-dev.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
# Run a PHP development server in docker
4+
5+
docker run \
6+
-i \
7+
--env 'ENVIRONMENT=development' \
8+
--expose 80 \
9+
--name php-solid-server \
10+
--network host \
11+
--rm \
12+
--volume "${PWD}:/app" \
13+
"php:${PHP_VERSION:-7.1}-alpine" \
14+
php \
15+
--define 'log_errors=On' \
16+
--docroot /app/web/ \
17+
--server '0.0.0.0:80' \
18+
/app/web/index.php

composer.json

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,43 @@
11
{
2+
"autoload": {
3+
"psr-4" :{
4+
"Pdsinterop\\Solid\\": "src/"
5+
}
6+
},
27
"config": {
8+
"bin-dir": "./bin",
9+
"platform": {
10+
"php": "7.1.33",
11+
"ext-dom": "0.0.0",
12+
"ext-mbstring": "0.0.0"
13+
},
314
"sort-packages": true
415
},
516
"description": "Standalone Solid Server written in PHP by PDS Interop.",
617
"license": "MIT",
718
"name": "pdsinterop/solid-server",
819
"require": {
9-
"php": "^7.1",
20+
"php": "~7.1",
1021
"ext-json": "*",
22+
"ext-mbstring": "*",
1123
"ext-openssl": "*",
12-
"defuse/php-encryption": "^2.2",
13-
"easyrdf/easyrdf": "^0.9",
14-
"laminas/laminas-diactoros": "^2.3",
15-
"laminas/laminas-httphandlerrunner": "^1.2",
16-
"league/container": "^3.3",
17-
"league/oauth2-server": "^8.1",
18-
"league/route": "^4.5",
19-
"php-http/httplug": "^2.1"
24+
"defuse/php-encryption":"^2.2",
25+
"laminas/laminas-diactoros":" ^2.3",
26+
"laminas/laminas-httphandlerrunner":"^1.2",
27+
"league/container":"^3.3",
28+
"league/flysystem":"^1.0.",
29+
"league/oauth2-server":"^8.0",
30+
"league/route":"^4.5",
31+
"pdsinterop/flysystem-rdf":"^0.1",
32+
"php-http/httplug":"^2.1"
2033
},
2134
"require-dev": {
2235
"phpunit/phpunit": "*"
2336
},
2437
"scripts": {
2538
"lint":"",
26-
"serve":"php -S \"${HOST:-localhost}:${PORT:-80}\" -t web/ web/index.php",
39+
"serve-dev":"ENVIRONMENT=development php -S \"${HOST:-localhost}:${PORT:-80}\" -t web/ web/index.php",
40+
"serve-dev-docker":"bash ./bin/serve-docker-dev.sh",
2741
"test":"phpunit"
2842
},
2943
"type": "project"

docker-compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: '3.3'
2+
3+
services:
4+
solid_php:
5+
command: "php --docroot /app/web/ --server 'localhost:80' /app/web/index.php"
6+
container_name: solid-php-server
7+
# environment variables can be passed from the host straight to a containers by not providing value
8+
environment:
9+
- ENVIRONMENT=development
10+
- PHP_VERSION
11+
ports:
12+
- "${PORT:-80}:80"
13+
image: "php:${PHP_VERSION:-7.1}"
14+
network_mode: host
15+
volumes:
16+
- ".:/app"

docs/spec-compliance/server.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Server
2+
3+
This document describes what the Solid specification demands from a server in
4+
general. Implementation details have been added describing if and how compliance
5+
has been reached.
6+
7+
## Spec compliance
8+
9+
- [x] _All http URIs MUST redirect to their https counterparts using a response with a 301 status code and a Location header._<br>
10+
![][ready] Implemented through the `Pdsinterop\Solid\Controller\HttpToHttpsController`.
11+
12+
- [ ] _It SHOULD additionally implement the server part of HTTP/1.1 Caching to improve performance_<br>
13+
![][maybe] As caching can be added "in-front" of the server this is deemed low-priority.
14+
15+
- [ ] _When a client does not provide valid credentials when requesting a resource that requires it, the data pod MUST send a response with a 401 status code (unless 404 is preferred for security reasons)._<br>
16+
![][later] This will need to be implemented as part of the OAuth, ACL, and protected documents parts.
17+
18+
- [ ] _A Solid server MUST reject PUT, POST and PATCH requests without the Content-Type header with a status code of 400._<br>
19+
![][todo] This should be added in a similar fashion as the HTTPtheHTTPS mechanism. No need to continue routing if this criteria is not met.
20+
21+
- [x] _Paths ending with a slash denote a container resource. the server MAY respond to requests for the latter URI with a 301 redirect to the former._<br>
22+
![][ready] Implemented through the `Pdsinterop\Solid\Controller\AddSlashToPathController`
23+
24+
[later]: https://img.shields.io/badge/resolution-later-important.svg
25+
[maybe]: https://img.shields.io/badge/resolution-maybe%20later-yellow.svg
26+
[ready]: https://img.shields.io/badge/resolution-done-success.svg
27+
[todo]: https://img.shields.io/badge/resolution-todo-critical.svg
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Pdsinterop\Solid\Controller;
4+
5+
use Psr\Http\Message\ResponseInterface;
6+
use Psr\Http\Message\ServerRequestInterface;
7+
8+
abstract class AbstractController
9+
{
10+
////////////////////////////// CLASS PROPERTIES \\\\\\\\\\\\\\\\\\\\\\\\\\\\
11+
12+
/** @var ResponseInterface */
13+
private $response;
14+
15+
//////////////////////////// GETTERS AND SETTERS \\\\\\\\\\\\\\\\\\\\\\\\\\\
16+
17+
final public function getResponse() : ResponseInterface
18+
{
19+
return $this->response;
20+
}
21+
22+
//////////////////////////////// PUBLIC API \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
23+
24+
public function __construct(ResponseInterface $response)
25+
{
26+
$this->response = $response;
27+
}
28+
29+
abstract public function __invoke(ServerRequestInterface $request, array $args) : ResponseInterface;
30+
31+
final public function createRedirectResponse(string $url, int $status = 302) : ResponseInterface
32+
{
33+
return $this->response->withHeader('location', $url)->withStatus($status);
34+
}
35+
36+
final public function createTextResponse(string $message, int $status = 200) : ResponseInterface
37+
{
38+
$body = $this->response->getBody();
39+
40+
$body->write($message);
41+
42+
return $this->response->withBody($body)->withStatus($status);
43+
}
44+
}

0 commit comments

Comments
 (0)