Merge branch 'main' into versions/3.0.0

# Conflicts:
#	package-lock.json
#	test/integration/Identity.test.ts
#	test/integration/RepresentationConverter.test.ts
This commit is contained in:
Joachim Van Herwegen
2022-01-25 11:44:24 +01:00
39 changed files with 1832 additions and 1808 deletions

View File

@@ -19,7 +19,7 @@ export class BearerWebIdExtractor extends CredentialsExtractor {
public async canHandle({ headers }: HttpRequest): Promise<void> {
const { authorization } = headers;
if (!authorization || !authorization.startsWith('Bearer ')) {
if (!authorization || !/^Bearer /ui.test(authorization)) {
throw new NotImplementedHttpError('No Bearer Authorization header specified.');
}
}

View File

@@ -27,7 +27,7 @@ export class DPoPWebIdExtractor extends CredentialsExtractor {
public async canHandle({ headers }: HttpRequest): Promise<void> {
const { authorization } = headers;
if (!authorization || !authorization.startsWith('DPoP ')) {
if (!authorization || !/^DPoP /ui.test(authorization)) {
throw new NotImplementedHttpError('No DPoP-bound Authorization header specified.');
}
}

View File

@@ -13,13 +13,13 @@ export class UnsecureWebIdExtractor extends CredentialsExtractor {
public async canHandle({ headers }: HttpRequest): Promise<void> {
const { authorization } = headers;
if (!authorization || !authorization.startsWith('WebID ')) {
if (!authorization || !/^WebID /ui.test(authorization)) {
throw new NotImplementedHttpError('No WebID Authorization header specified.');
}
}
public async handle({ headers }: HttpRequest): Promise<CredentialSet> {
const webId = /^WebID\s+(.*)/u.exec(headers.authorization!)![1];
const webId = /^WebID\s+(.*)/ui.exec(headers.authorization!)![1];
this.logger.info(`Agent unsecurely claims to be ${webId}`);
return { [CredentialGroup.agent]: { webId }};
}

View File

@@ -1,10 +1,9 @@
/* eslint-disable @typescript-eslint/naming-convention, import/no-unresolved, tsdoc/syntax */
/* eslint-disable @typescript-eslint/naming-convention, tsdoc/syntax */
// import/no-unresolved can't handle jose imports
// tsdoc/syntax can't handle {json} parameter
import { randomBytes } from 'crypto';
import type { JWK } from 'jose/jwk/from_key_like';
import { fromKeyLike } from 'jose/jwk/from_key_like';
import { generateKeyPair } from 'jose/util/generate_key_pair';
import type { JWK } from 'jose';
import { exportJWK, generateKeyPair } from 'jose';
import type { AnyObject,
CanBePromise,
KoaContextWithOIDC,
@@ -135,7 +134,7 @@ export class IdentityProviderFactory implements ProviderFactory {
// Cast necessary due to typing conflict between jose 2.x and 3.x
config.jwks = await this.generateJwks() as any;
config.cookies = {
...config.cookies ?? {},
...config.cookies,
keys: await this.generateCookieKeys(),
};
@@ -154,7 +153,7 @@ export class IdentityProviderFactory implements ProviderFactory {
}
// If they are not, generate and save them
const { privateKey } = await generateKeyPair('RS256');
const jwk = await fromKeyLike(privateKey);
const jwk = await exportJWK(privateKey);
// Required for Solid authn client
jwk.alg = 'RS256';
// In node v15.12.0 the JWKS does not get accepted because the JWK is not a plain object,