feat: add additional supported interfaces

This includes the relevant auth headers and a simplification of several others.
This commit is contained in:
Joachim Van Herwegen
2020-05-25 11:05:04 +02:00
parent f8e136cadb
commit a4f2b3995c
12 changed files with 107 additions and 35 deletions

View File

@@ -0,0 +1,23 @@
import { Credentials } from '../authentication/Credentials';
import { PermissionSet } from '../ldp/permissions/PermissionSet';
import { ResourceIdentifier } from '../ldp/http/ResourceIdentifier';
/**
* Responsible for the permission verification.
*/
export interface Authorizer {
/**
* Verifies if the given credentials have access to the given permissions on the given resource.
* @param credentials - Credentials of the entity that wants to use the resource.
* @param identifier - Identifier of the resource that will be read/modified.
* @param permissions - Permissions that are requested on the resource.
*
* @returns A promise resolving when the Authorizer is finished.
* An {@link Error} with the necessary explanation will be thrown when permissions are not granted.
*/
ensurePermissions: (
credentials: Credentials,
identifier: ResourceIdentifier,
permissions: PermissionSet,
) => Promise<void>;
}