Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creator POST Handler #1

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Community Solid Server
# Community Solid Server - MANDAT Fork

## Features added for MANDAT
- A handler for POST requests (creating a resource) that allows the creator of the resource to automatically have access to the resource by creating the corresponding ACL ([further explanation](/documentation/markdown/mandat/creator-post-handler.md))


## Community Solid Server

<img src="https://raw.githubusercontent.com/CommunitySolidServer/CommunitySolidServer/main/templates/images/solid.svg"
alt="[Solid logo]" height="150" align="right"/>
Expand Down
2 changes: 1 addition & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"css:config/identity/pod/static.json",
"css:config/ldp/authentication/dpop-bearer.json",
"css:config/ldp/authorization/webacl.json",
"css:config/ldp/handler/default.json",
"css:config/ldp/handler/with-creator.json",
"css:config/ldp/metadata-parser/default.json",
"css:config/ldp/metadata-writer/default.json",
"css:config/ldp/modes/default.json",
Expand Down
2 changes: 1 addition & 1 deletion config/dynamic.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"css:config/identity/pod/dynamic.json",
"css:config/ldp/authentication/dpop-bearer.json",
"css:config/ldp/authorization/webacl.json",
"css:config/ldp/handler/default.json",
"css:config/ldp/handler/with-creator.json",
"css:config/ldp/metadata-parser/default.json",
"css:config/ldp/metadata-writer/default.json",
"css:config/ldp/modes/default.json",
Expand Down
2 changes: 1 addition & 1 deletion config/example-https-file.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"css:config/identity/pod/static.json",
"css:config/ldp/authentication/dpop-bearer.json",
"css:config/ldp/authorization/webacl.json",
"css:config/ldp/handler/default.json",
"css:config/ldp/handler/with-creator.json",
"css:config/ldp/metadata-parser/default.json",
"css:config/ldp/metadata-writer/default.json",
"css:config/ldp/modes/default.json",
Expand Down
2 changes: 1 addition & 1 deletion config/file-acp.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"css:config/identity/pod/static.json",
"css:config/ldp/authentication/dpop-bearer.json",
"css:config/ldp/authorization/acp.json",
"css:config/ldp/handler/default.json",
"css:config/ldp/handler/with-creator.json",
"css:config/ldp/metadata-parser/default.json",
"css:config/ldp/metadata-writer/default.json",
"css:config/ldp/modes/default.json",
Expand Down
2 changes: 1 addition & 1 deletion config/file-root-pod.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"css:config/identity/pod/static.json",
"css:config/ldp/authentication/dpop-bearer.json",
"css:config/ldp/authorization/webacl.json",
"css:config/ldp/handler/default.json",
"css:config/ldp/handler/with-creator",
"css:config/ldp/metadata-parser/default.json",
"css:config/ldp/metadata-writer/default.json",
"css:config/ldp/modes/default.json",
Expand Down
2 changes: 1 addition & 1 deletion config/file-root.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"css:config/identity/pod/static.json",
"css:config/ldp/authentication/dpop-bearer.json",
"css:config/ldp/authorization/webacl.json",
"css:config/ldp/handler/default.json",
"css:config/ldp/handler/with-creator",
"css:config/ldp/metadata-parser/default.json",
"css:config/ldp/metadata-writer/default.json",
"css:config/ldp/modes/default.json",
Expand Down
2 changes: 1 addition & 1 deletion config/file.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"css:config/identity/pod/static.json",
"css:config/ldp/authentication/dpop-bearer.json",
"css:config/ldp/authorization/webacl.json",
"css:config/ldp/handler/default.json",
"css:config/ldp/handler/with-creator",
"css:config/ldp/metadata-parser/default.json",
"css:config/ldp/metadata-writer/default.json",
"css:config/ldp/modes/default.json",
Expand Down
2 changes: 1 addition & 1 deletion config/https-file-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"css:config/identity/pod/static.json",
"css:config/ldp/authentication/dpop-bearer.json",
"css:config/ldp/authorization/webacl.json",
"css:config/ldp/handler/default.json",
"css:config/ldp/handler/with-creator",
"css:config/ldp/metadata-parser/default.json",
"css:config/ldp/metadata-writer/default.json",
"css:config/ldp/modes/default.json",
Expand Down
57 changes: 57 additions & 0 deletions config/ldp/handler/components/operation-handler-with-creator.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^7.0.0/components/context.jsonld",
"@graph": [
{
"@id": "urn:solid-server:default:OperationHandler",
"@type": "WaterfallHandler",
"handlers": [
{
"@type": "GetOperationHandler",
"store": { "@id": "urn:solid-server:default:ResourceStore" },
"eTagHandler": { "@id": "urn:solid-server:default:ETagHandler" }
},
{
"@type": "CreatorPostOperationHandler",
"store": { "@id": "urn:solid-server:default:ResourceStore" },
"creatorContainerNamesAndModes": [
["demands", [
"Read",
"Append"
]]
],
"aclStrategy": { "@id": "urn:solid-server:default:AclStrategy" },
"credentialsExtractor": { "@id": "urn:solid-server:default:CredentialsExtractor" },
"resourceSet": { "@id": "urn:solid-server:default:CachedResourceSet" },
"identifierStrategy": { "@id": "urn:solid-server:default:IdentifierStrategy" },
"aclStore": { "@id": "urn:solid-server:default:ResourceStore" }
},
{
"@type": "PostOperationHandler",
"store": { "@id": "urn:solid-server:default:ResourceStore" }
},
{
"@type": "PutOperationHandler",
"store": { "@id": "urn:solid-server:default:ResourceStore" },
"metadataStrategy":{ "@id": "urn:solid-server:default:MetadataStrategy" }
},
{
"@type": "DeleteOperationHandler",
"store": { "@id": "urn:solid-server:default:ResourceStore" }
},
{
"@type": "HeadOperationHandler",
"store": { "@id": "urn:solid-server:default:ResourceStore" },
"eTagHandler": { "@id": "urn:solid-server:default:ETagHandler" }
},
{
"@type": "PatchOperationHandler",
"store": { "@id": "urn:solid-server:default:ResourceStore" }
},
{
"@type": "StaticThrowHandler",
"error": { "@type": "MethodNotAllowedHttpError" }
}
]
}
]
}
2 changes: 1 addition & 1 deletion config/ldp/handler/components/operation-handler.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@
]
}
]
}
}
36 changes: 36 additions & 0 deletions config/ldp/handler/with-creator.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^7.0.0/components/context.jsonld",
"import": [
"css:config/ldp/handler/components/authorizer.json",
"css:config/ldp/handler/components/error-handler.json",
"css:config/ldp/handler/components/operation-handler-with-creator.json",
"css:config/ldp/handler/components/operation-metadata.json",
"css:config/ldp/handler/components/preferences.json",
"css:config/ldp/handler/components/request-parser.json",
"css:config/ldp/handler/components/response-writer.json"
],
"@graph": [
{
"comment": "The main entry point into the main Solid behaviour.",
"@id": "urn:solid-server:default:LdpHandler",
"@type": "ParsingHttpHandler",
"args_requestParser": { "@id": "urn:solid-server:default:RequestParser" },
"args_errorHandler": { "@id": "urn:solid-server:default:ErrorHandler" },
"args_responseWriter": { "@id": "urn:solid-server:default:ResponseWriter" },
"args_operationHandler": {
"@type": "AuthorizingHttpHandler",
"args_credentialsExtractor": { "@id": "urn:solid-server:default:CredentialsExtractor" },
"args_modesExtractor": { "@id": "urn:solid-server:default:ModesExtractor" },
"args_permissionReader": { "@id": "urn:solid-server:default:PermissionReader" },
"args_authorizer": { "@id": "urn:solid-server:default:Authorizer" },
"args_operationHandler": {
"@type": "WacAllowHttpHandler",
"args_credentialsExtractor": { "@id": "urn:solid-server:default:CredentialsExtractor" },
"args_modesExtractor": { "@id": "urn:solid-server:default:ModesExtractor" },
"args_permissionReader": { "@id": "urn:solid-server:default:PermissionReader" },
"args_operationHandler": { "@id": "urn:solid-server:default:OperationHandler" }
}
}
}
]
}
2 changes: 1 addition & 1 deletion config/memory-subdomains.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"css:config/identity/pod/static.json",
"css:config/ldp/authentication/dpop-bearer.json",
"css:config/ldp/authorization/webacl.json",
"css:config/ldp/handler/default.json",
"css:config/ldp/handler/with-creator",
"css:config/ldp/metadata-parser/default.json",
"css:config/ldp/metadata-writer/default.json",
"css:config/ldp/modes/default.json",
Expand Down
2 changes: 1 addition & 1 deletion config/path-routing.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"css:config/identity/pod/static.json",
"css:config/ldp/authentication/dpop-bearer.json",
"css:config/ldp/authorization/webacl.json",
"css:config/ldp/handler/default.json",
"css:config/ldp/handler/with-creator",
"css:config/ldp/metadata-parser/default.json",
"css:config/ldp/metadata-writer/default.json",
"css:config/ldp/modes/default.json",
Expand Down
2 changes: 1 addition & 1 deletion config/quota-file.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"css:config/identity/pod/static.json",
"css:config/ldp/authentication/dpop-bearer.json",
"css:config/ldp/authorization/webacl.json",
"css:config/ldp/handler/default.json",
"css:config/ldp/handler/with-creator",
"css:config/ldp/metadata-parser/default.json",
"css:config/ldp/metadata-writer/default.json",
"css:config/ldp/modes/default.json",
Expand Down
2 changes: 1 addition & 1 deletion config/restrict-idp.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"css:config/identity/pod/static.json",
"css:config/ldp/authentication/dpop-bearer.json",
"css:config/ldp/authorization/webacl.json",
"css:config/ldp/handler/default.json",
"css:config/ldp/handler/with-creator",
"css:config/ldp/metadata-parser/default.json",
"css:config/ldp/metadata-writer/default.json",
"css:config/ldp/modes/default.json",
Expand Down
2 changes: 1 addition & 1 deletion config/sparql-endpoint-root.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"css:config/identity/pod/static.json",
"css:config/ldp/authentication/dpop-bearer.json",
"css:config/ldp/authorization/webacl.json",
"css:config/ldp/handler/default.json",
"css:config/ldp/handler/with-creator",
"css:config/ldp/metadata-parser/default.json",
"css:config/ldp/metadata-writer/default.json",
"css:config/ldp/modes/default.json",
Expand Down
2 changes: 1 addition & 1 deletion config/sparql-endpoint.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"css:config/identity/pod/static.json",
"css:config/ldp/authentication/dpop-bearer.json",
"css:config/ldp/authorization/webacl.json",
"css:config/ldp/handler/default.json",
"css:config/ldp/handler/with-creator",
"css:config/ldp/metadata-parser/default.json",
"css:config/ldp/metadata-writer/default.json",
"css:config/ldp/modes/default.json",
Expand Down
2 changes: 1 addition & 1 deletion config/sparql-file-storage.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"css:config/identity/pod/static.json",
"css:config/ldp/authentication/dpop-bearer.json",
"css:config/ldp/authorization/webacl.json",
"css:config/ldp/handler/default.json",
"css:config/ldp/handler/with-creator",
"css:config/ldp/metadata-parser/default.json",
"css:config/ldp/metadata-writer/default.json",
"css:config/ldp/modes/default.json",
Expand Down
15 changes: 15 additions & 0 deletions documentation/markdown/mandat/creator-post-handler.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Creator Post Handler
A handler for POST requests (creating a resource) that allows the creator of the resource to automatically have access to the resource by creating the corresponding ACL

## Config
The handlers we are interested in are configured in [/config/ldp/handlers/components/operation-handler.json](../../../config/ldp/handler/components/operation-handler.json). We copied the file to [/config/ldp/handlers/components/operation-handler-with-creator.json](../../../config/ldp/handler/components/operation-handler-with-creator.json) and added a `CreatorPostOperationHandler` to the waterfall handler before the normal `PostOperationHandler`.

The `CreatorPostOperationHandler` is configured as follows: Under `creatorContainerNamesAndModes` we can add an array of pairs where the first element of the pair is the name of the container to which the handler should apply and the second element of the pair is a list of ACL access modes that should be given to the creator of resources in this container.

To use [/config/ldp/handlers/components/operation-handler-with-creator.json](../../../config/ldp/handler/components/operation-handler-with-creator.json) instead of [/config/ldp/handlers/components/operation-handler.json](../../../config/ldp/handler/components/operation-handler.json) we also created the config file [/config/ldp/handler/with-creator.json](../../../config/ldp/handler/with-creator.json) as alternative to [/config/ldp/handler/default.json](../../../config/ldp/handler/default.json) and added it to the provided global config files (e.g. [/config/default.json](../../../config/default.json), [/config/file.json](../../../config/file.json)).

## Code
All implementation has been done in the class [/src/http/ldp/CreatorPostOperationHandler.ts](../../../src/http/ldp/CreatorPostOperationHandler.ts).

## Contributors
[dschraudner](https://github.com/dschraudner), [se-schmid](https://github.com/se-schmid), [kaefer3000](https://github.com/kaefer3000)
Loading