-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
1,917 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^2.0.0/components/context.jsonld", | ||
"@graph": [ | ||
{ | ||
"comment": "Converts content-length headers into RDF metadata.", | ||
"@id": "urn:solid-server:default:ContentLengthParser", | ||
"@type": "ContentLengthParser" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^2.0.0/components/context.jsonld", | ||
"import": [ | ||
"files-scs:config/app/main/default.json", | ||
"files-scs:config/app/init/default.json", | ||
"files-scs:config/app/setup/required.json", | ||
"files-scs:config/http/handler/default.json", | ||
"files-scs:config/http/middleware/websockets.json", | ||
"files-scs:config/http/server-factory/websockets.json", | ||
"files-scs:config/http/static/default.json", | ||
"files-scs:config/identity/access/public.json", | ||
"files-scs:config/identity/email/default.json", | ||
"files-scs:config/identity/handler/default.json", | ||
"files-scs:config/identity/ownership/token.json", | ||
"files-scs:config/identity/pod/static.json", | ||
"files-scs:config/identity/registration/enabled.json", | ||
"files-scs:config/ldp/authentication/dpop-bearer.json", | ||
"files-scs:config/ldp/authorization/allow-all.json", | ||
"files-scs:config/ldp/handler/default.json", | ||
"files-scs:config/ldp/metadata-parser/default.json", | ||
"files-scs:config/ldp/metadata-writer/default.json", | ||
"files-scs:config/ldp/modes/default.json", | ||
"files-scs:config/storage/backend/pod-quota-file.json", | ||
"files-scs:config/storage/key-value/resource-store.json", | ||
"files-scs:config/storage/middleware/default.json", | ||
"files-scs:config/util/auxiliary/acl.json", | ||
"files-scs:config/util/identifiers/suffix.json", | ||
"files-scs:config/util/index/default.json", | ||
"files-scs:config/util/logging/winston.json", | ||
"files-scs:config/util/representation-conversion/default.json", | ||
"files-scs:config/util/resource-locker/memory.json", | ||
"files-scs:config/util/variables/default.json" | ||
], | ||
"@graph": [ | ||
{ | ||
"comment": "A single-pod server that stores its resources on disk while enforcing quota." | ||
}, | ||
{ | ||
"@id": "urn:solid-server:default:QuotaStrategy", | ||
"PodQuotaStrategy:_limit_amount": 7000, | ||
"PodQuotaStrategy:_limit_unit": "bytes", | ||
"GlobalQuotaStrategy:_limit_amount": 10000, | ||
"GlobalQuotaStrategy:_limit_unit": "bytes" | ||
}, | ||
{ | ||
"@id": "urn:solid-server:default:SizeReporter", | ||
"FileSizeReporter:_ignoreFolders": [ "^/\\.internal$" ] | ||
} | ||
] | ||
} |
45 changes: 45 additions & 0 deletions
45
config/storage/backend/data-accessors/global-quota-file.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^2.0.0/components/context.jsonld", | ||
"comment": "DataAccessor configuration using a GlobalQuotaStrategy to enforce quota globally on the server", | ||
"@graph": [ | ||
{ | ||
"comment": "DataAccessor that writes data to the disk with atomicity in mind", | ||
"@id": "urn:solid-server:default:AtomicFileDataAccessor", | ||
"@type": "AtomicFileDataAccessor", | ||
"resourceMapper": { "@id": "urn:solid-server:default:FileIdentifierMapper" }, | ||
"rootFilePath": { "@id": "urn:solid-server:default:variable:rootFilePath" }, | ||
"tempFilePath": "/.internal/tempFiles/" | ||
}, | ||
|
||
{ | ||
"comment": "Calculates the space already taken up by a resource", | ||
"@id": "urn:solid-server:default:SizeReporter", | ||
"@type": "FileSizeReporter", | ||
"fileIdentifierMapper": { "@id": "urn:solid-server:default:FileIdentifierMapper" }, | ||
"rootFilePath": { "@id": "urn:solid-server:default:variable:rootFilePath" }, | ||
}, | ||
|
||
{ | ||
"comment": "Enforces quota globally for all data on the server", | ||
"@id": "urn:solid-server:default:QuotaStrategy", | ||
"@type": "GlobalQuotaStrategy", | ||
"reporter": { "@id": "urn:solid-server:default:SizeReporter" }, | ||
"base": { "@id": "urn:solid-server:default:variable:baseUrl" } | ||
}, | ||
|
||
{ | ||
"comment": "Validates the data being written to the server", | ||
"@id": "urn:solid-server:default:QuotaValidator", | ||
"@type": "QuotaValidator", | ||
"strategy": { "@id": "urn:solid-server:default:QuotaStrategy" } | ||
}, | ||
|
||
{ | ||
"comment": "Simple wrapper for another DataAccessor but adds validation", | ||
"@id": "urn:solid-server:default:FileDataAccessor", | ||
"@type": "ValidatingDataAccessor", | ||
"accessor": { "@id": "urn:solid-server:default:AtomicFileDataAccessor" }, | ||
"validator": { "@id": "urn:solid-server:default:QuotaValidator" } | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^2.0.0/components/context.jsonld", | ||
"comment": "DataAccessor configuration using a PodQuotaStrategy to enforce pod quotas on the server", | ||
"@graph": [ | ||
{ | ||
"comment": "DataAccessor that writes data to the disk with atomicity in mind", | ||
"@id": "urn:solid-server:default:AtomicFileDataAccessor", | ||
"@type": "AtomicFileDataAccessor", | ||
"resourceMapper": { "@id": "urn:solid-server:default:FileIdentifierMapper" }, | ||
"rootFilePath": { "@id": "urn:solid-server:default:variable:rootFilePath" }, | ||
"tempFilePath": "/.internal/tempFiles/" | ||
}, | ||
|
||
{ | ||
"comment": "Calculates the space already taken up by a resource", | ||
"@id": "urn:solid-server:default:SizeReporter", | ||
"@type": "FileSizeReporter", | ||
"fileIdentifierMapper": { "@id": "urn:solid-server:default:FileIdentifierMapper" }, | ||
"rootFilePath": { "@id": "urn:solid-server:default:variable:rootFilePath" }, | ||
}, | ||
|
||
{ | ||
"comment": "Enforces quota for all data per pod on the server", | ||
"@id": "urn:solid-server:default:QuotaStrategy", | ||
"@type": "PodQuotaStrategy", | ||
"reporter": { "@id": "urn:solid-server:default:SizeReporter" }, | ||
"accessor": { "@id": "urn:solid-server:default:AtomicFileDataAccessor" }, | ||
"identifierStrategy": { "@id": "urn:solid-server:default:IdentifierStrategy" } | ||
}, | ||
|
||
{ | ||
"comment": "Validates the data being written to the server", | ||
"@id": "urn:solid-server:default:QuotaValidator", | ||
"@type": "QuotaValidator", | ||
"strategy": { "@id": "urn:solid-server:default:QuotaStrategy" } | ||
}, | ||
|
||
{ | ||
"comment": "Simple wrapper for another DataAccessor but adds validation", | ||
"@id": "urn:solid-server:default:FileDataAccessor", | ||
"@type": "ValidatingDataAccessor", | ||
"accessor": { "@id": "urn:solid-server:default:AtomicFileDataAccessor" }, | ||
"validator": { "@id": "urn:solid-server:default:QuotaValidator" } | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^2.0.0/components/context.jsonld", | ||
"import": [ | ||
"files-scs:config/storage/backend/data-accessors/global-quota-file.json" | ||
], | ||
"@graph": [ | ||
{ | ||
"comment": "A default store setup with a file system backend.", | ||
"@id": "urn:solid-server:default:ResourceStore_Backend", | ||
"@type": "DataAccessorBasedStore", | ||
"identifierStrategy": { "@id": "urn:solid-server:default:IdentifierStrategy" }, | ||
"auxiliaryStrategy": { "@id": "urn:solid-server:default:AuxiliaryStrategy" }, | ||
"accessor": { "@id": "urn:solid-server:default:FileDataAccessor" } | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^2.0.0/components/context.jsonld", | ||
"import": [ | ||
"files-scs:config/storage/backend/data-accessors/pod-quota-file.json" | ||
], | ||
"@graph": [ | ||
{ | ||
"comment": "A default store setup with a file system backend.", | ||
"@id": "urn:solid-server:default:ResourceStore_Backend", | ||
"@type": "DataAccessorBasedStore", | ||
"identifierStrategy": { "@id": "urn:solid-server:default:IdentifierStrategy" }, | ||
"auxiliaryStrategy": { "@id": "urn:solid-server:default:AuxiliaryStrategy" }, | ||
"accessor": { "@id": "urn:solid-server:default:FileDataAccessor" } | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
import { AsyncHandler } from '../../util/handlers/AsyncHandler'; | ||
import type { Representation } from '../representation/Representation'; | ||
import type { ResourceIdentifier } from '../representation/ResourceIdentifier'; | ||
|
||
export type ValidatorInput = { | ||
representation: Representation; | ||
identifier: ResourceIdentifier; | ||
}; | ||
|
||
/** | ||
* Generic interface for classes that validate Representations in some way. | ||
*/ | ||
export abstract class Validator extends AsyncHandler<Representation> { } | ||
export abstract class Validator extends AsyncHandler<ValidatorInput, Representation> { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { getLoggerFor } from '../../../logging/LogUtil'; | ||
import type { HttpRequest } from '../../../server/HttpRequest'; | ||
import type { RepresentationMetadata } from '../../representation/RepresentationMetadata'; | ||
import { MetadataParser } from './MetadataParser'; | ||
|
||
/** | ||
* Parser for the `content-length` header. | ||
*/ | ||
export class ContentLengthParser extends MetadataParser { | ||
protected readonly logger = getLoggerFor(this); | ||
|
||
public async handle(input: { request: HttpRequest; metadata: RepresentationMetadata }): Promise<void> { | ||
const contentLength = input.request.headers['content-length']; | ||
if (contentLength) { | ||
const length = /^\s*(\d+)\s*(?:;.*)?$/u.exec(contentLength)?.[1]; | ||
if (length) { | ||
input.metadata.contentLength = Number(length); | ||
} else { | ||
this.logger.warn(`Invalid content-length header found: ${contentLength}.`); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { DataAccessor } from './DataAccessor'; | ||
|
||
/** | ||
* The AtomicDataAccessor interface has identical function signatures as | ||
* the DataAccessor, with the additional constraint that every function call | ||
* must be atomic in its effect: either the call fully succeeds, reaching the | ||
* desired new state; or it fails, upon which the resulting state remains | ||
* identical to the one before the call. | ||
*/ | ||
export interface AtomicDataAccessor extends DataAccessor { } |
Oops, something went wrong.