fix: clean up structure using more AsyncHandlers and more folders

This commit is contained in:
Joachim Van Herwegen
2020-05-28 10:53:35 +02:00
parent 14cfe75865
commit cc8f965495
16 changed files with 33 additions and 37 deletions

View File

@@ -1,23 +1,25 @@
import { AsyncHandler } from '../util/AsyncHandler';
import { Credentials } from '../authentication/Credentials';
import { PermissionSet } from '../ldp/permissions/PermissionSet';
import { ResourceIdentifier } from '../ldp/http/ResourceIdentifier';
import { ResourceIdentifier } from '../ldp/representation/ResourceIdentifier';
/**
* Responsible for the permission verification.
* Verifies if the given credentials have access to the given permissions on the given resource.
* An {@link Error} with the necessary explanation will be thrown when permissions are not granted.
*/
export interface Authorizer {
export type Authorizer = AsyncHandler<AuthorizerArgs>;
export interface AuthorizerArgs {
/**
* 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.
* Credentials of the entity that wants to use the resource.
*/
ensurePermissions: (
credentials: Credentials,
identifier: ResourceIdentifier,
permissions: PermissionSet,
) => Promise<void>;
credentials: Credentials;
/**
* Identifier of the resource that will be read/modified.
*/
identifier: ResourceIdentifier;
/**
* Permissions that are requested on the resource.
*/
permissions: PermissionSet;
}