mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
docs: Clarify ownership validation message.
This commit is contained in:
parent
d3de5f3114
commit
c1d8f0e841
@ -82,11 +82,15 @@ export class TokenOwnershipValidator extends OwnershipValidator {
|
|||||||
* Throws an error containing the description of which triple is needed for verification.
|
* Throws an error containing the description of which triple is needed for verification.
|
||||||
*/
|
*/
|
||||||
private throwError(webId: string, token: string): never {
|
private throwError(webId: string, token: string): never {
|
||||||
this.logger.debug(`Missing verification token at ${webId}`);
|
this.logger.debug(`No verification token found for ${webId}`);
|
||||||
const errorMessage = [
|
const errorMessage = [
|
||||||
`<${webId}> <${SOLID.terms.oidcIssuerRegistrationToken.value}> "${token}" .`,
|
'Verification token not found.',
|
||||||
'Must be added to the WebId. This can be removed after registration.',
|
'Please add the RDF triple',
|
||||||
].join('\n');
|
`<${webId}> <${SOLID.oidcIssuerRegistrationToken}> "${token}".`,
|
||||||
|
`to the WebID document at ${webId.replace(/#.*/u, '')}`,
|
||||||
|
'to prove it belongs to you.',
|
||||||
|
'You can remove this triple again after validation.',
|
||||||
|
].join(' ');
|
||||||
throw new BadRequestHttpError(errorMessage);
|
throw new BadRequestHttpError(errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,16 +34,13 @@ async function postForm(url: string, formBody: string): Promise<Response> {
|
|||||||
* Extracts the registration triple from the registration form body.
|
* Extracts the registration triple from the registration form body.
|
||||||
*/
|
*/
|
||||||
function extractRegistrationTriple(body: string, webId: string): string {
|
function extractRegistrationTriple(body: string, webId: string): string {
|
||||||
const error = load(body)('p.error').first().text().trim()
|
const error = load(body)('p.error').first().text();
|
||||||
.split('\n')[0];
|
|
||||||
const regex = new RegExp(
|
const regex = new RegExp(
|
||||||
`(<${webId}> <http://www.w3.org/ns/solid/terms#oidcIssuerRegistrationToken> "[^"]+"\\s*\\.\\s*)$`, 'u',
|
`<${webId}>\\s+<http://www.w3.org/ns/solid/terms#oidcIssuerRegistrationToken>\\s+"[^"]+"\\s*\\.`, 'u',
|
||||||
);
|
);
|
||||||
const match = regex.exec(error);
|
const match = regex.exec(error);
|
||||||
expect(match).toHaveLength(2);
|
expect(match).toHaveLength(1);
|
||||||
const registrationTriple = match![1];
|
return match![0];
|
||||||
expect(registrationTriple).not.toHaveLength(0);
|
|
||||||
return registrationTriple;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// No way around the cookies https://github.com/panva/node-oidc-provider/issues/552 .
|
// No way around the cookies https://github.com/panva/node-oidc-provider/issues/552 .
|
||||||
|
@ -24,7 +24,7 @@ describe('A TokenOwnershipValidator', (): void => {
|
|||||||
const webId = 'http://alice.test.com/#me';
|
const webId = 'http://alice.test.com/#me';
|
||||||
const token = 'randomlyGeneratedToken';
|
const token = 'randomlyGeneratedToken';
|
||||||
const tokenTriple = quad(namedNode(webId), SOLID.terms.oidcIssuerRegistrationToken, literal(token));
|
const tokenTriple = quad(namedNode(webId), SOLID.terms.oidcIssuerRegistrationToken, literal(token));
|
||||||
const tokenString = `${quadToString(tokenTriple)} .`;
|
const tokenString = `${quadToString(tokenTriple)}.`;
|
||||||
const converter = new RdfToQuadConverter();
|
const converter = new RdfToQuadConverter();
|
||||||
let storage: ExpiringStorage<string, string>;
|
let storage: ExpiringStorage<string, string>;
|
||||||
let validator: TokenOwnershipValidator;
|
let validator: TokenOwnershipValidator;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user