gatehouse-ts
    Preparing search index...

    Class PermissionChecker<Sub, Res, Act, Ctx>

    Main class for evaluating access permissions. Add multiple policies to it, and it will evaluate them sequentially until one grants access.

    const checker = new PermissionChecker<User, Document, string, RequestContext>();
    checker.addPolicy(adminPolicy);
    checker.addPolicy(ownerPolicy);
    const result = await checker.evaluateAccess({
    subject: currentUser,
    resource: document,
    action: "edit",
    context: requestContext
    });
    if (result.isGranted()) {
    // Allow access
    }

    Type Parameters

    • Sub

      The type of the subject requesting access

    • Res

      The type of resource being accessed

    • Act

      The type of action being performed

    • Ctx

      Additional contextual information

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    name: string = 'PermissionChecker'

    Methods

    • Adds a policy to the permission checker. Policies are evaluated in the order they're added, with OR semantics.

      Parameters

      Returns void

    • Evaluates access based on the configured policies. Policies are evaluated sequentially with OR semantics (short-circuiting on first success).

      Parameters

      • __namedParameters: { action: Act; context: Ctx; resource: Res; subject: Sub }

      Returns Promise<AccessEvaluation>

      AccessEvaluation result with details about the decision