Skip to content

Commit

Permalink
fix: Hide internal data by making it auxiliary
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimvh committed Sep 9, 2021
1 parent e31cd38 commit 1821252
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
13 changes: 13 additions & 0 deletions config/storage/key-value/resource-store.json
Expand Up @@ -56,6 +56,19 @@
"PathBasedAuthorizer:_paths_value": { "@type": "DenyAllAuthorizer" }
}
]
},
{
"comment": "Marks the /.internal/ storage container as an auxiliary resource, thereby hiding it from container representations.",
"@id": "urn:solid-server:default:AuxiliaryStrategy",
"RoutingAuxiliaryStrategy:_sources": [
{
"@type": "ComposedAuxiliaryStrategy",
"identifierStrategy": {
"@type": "SuffixAuxiliaryIdentifierStrategy",
"suffix": "/.internal/"
}
}
]
}
]
}
2 changes: 1 addition & 1 deletion src/ldp/auxiliary/AuxiliaryStrategy.ts
Expand Up @@ -10,7 +10,7 @@ import type { AuxiliaryIdentifierStrategy } from './AuxiliaryIdentifierStrategy'
*/
export interface AuxiliaryStrategy extends AuxiliaryIdentifierStrategy {
/**
* Whether this auxiliary resource in a root storage container.
* Whether this auxiliary resource is required in a root storage container.
* If yes, this means they can't be deleted individually from such a container.
* @param identifier - Identifier of the auxiliary resource.
*/
Expand Down
10 changes: 6 additions & 4 deletions test/integration/LdpHandlerWithoutAuth.test.ts
@@ -1,6 +1,6 @@
import { createReadStream } from 'fs';
import fetch from 'cross-fetch';
import { DataFactory, Parser } from 'n3';
import { DataFactory, Parser, Store } from 'n3';
import { joinFilePath, PIM, RDF } from '../../src/';
import type { App } from '../../src/';
import { LDP } from '../../src/util/Vocabularies';
Expand Down Expand Up @@ -90,9 +90,11 @@ describe.each(stores)('An LDP handler allowing all requests %s', (name, { storeC

const parser = new Parser({ baseIRI: baseUrl });
const quads = parser.parse(await response.text());
expect(quads.some((entry): boolean => entry.equals(
quad(namedNode(baseUrl), RDF.terms.type, LDP.terms.Container),
))).toBe(true);
const store = new Store(quads);
expect(store.countQuads(namedNode(baseUrl), RDF.terms.type, LDP.terms.Container, null)).toBe(1);
const contains = store.getObjects(namedNode(baseUrl), LDP.terms.contains, null);
expect(contains).toHaveLength(1);
expect(contains[0].value).toBe(`${baseUrl}index.html`);
});

it('can add a document to the store, read it and delete it.', async(): Promise<void> => {
Expand Down

0 comments on commit 1821252

Please sign in to comment.