feat: Support acl authorization for IDP components

Configuration has been updated so the IDP requests
also pass through an Authorization component.
A new config option was added to choose
which authorization scheme to use for the IDP.
This commit is contained in:
Joachim Van Herwegen
2021-09-27 09:13:27 +02:00
parent 9968f2ae5b
commit 13c49045d4
44 changed files with 401 additions and 75 deletions

View File

@@ -1,21 +0,0 @@
import { CredentialGroup } from '../../../src/authentication/Credentials';
import { EmptyCredentialsExtractor } from '../../../src/authentication/EmptyCredentialsExtractor';
import type { HttpRequest } from '../../../src/server/HttpRequest';
import { NotImplementedHttpError } from '../../../src/util/errors/NotImplementedHttpError';
describe('An EmptyCredentialsExtractor', (): void => {
const extractor = new EmptyCredentialsExtractor();
it('throws an error if an Authorization header is specified.', async(): Promise<void> => {
const headers = { authorization: 'Other http://alice.example/card#me' };
const result = extractor.handleSafe({ headers } as HttpRequest);
await expect(result).rejects.toThrow(NotImplementedHttpError);
await expect(result).rejects.toThrow('Unexpected Authorization scheme.');
});
it('returns the empty credentials.', async(): Promise<void> => {
const headers = {};
const result = extractor.handleSafe({ headers } as HttpRequest);
await expect(result).resolves.toEqual({ [CredentialGroup.public]: {}});
});
});

View File

@@ -0,0 +1,13 @@
import { CredentialGroup } from '../../../src/authentication/Credentials';
import { PublicCredentialsExtractor } from '../../../src/authentication/PublicCredentialsExtractor';
import type { HttpRequest } from '../../../src/server/HttpRequest';
describe('A PublicCredentialsExtractor', (): void => {
const extractor = new PublicCredentialsExtractor();
it('returns the empty credentials.', async(): Promise<void> => {
const headers = {};
const result = extractor.handleSafe({ headers } as HttpRequest);
await expect(result).resolves.toEqual({ [CredentialGroup.public]: {}});
});
});