Class ApiXAccessLevelEvaluator

A class that evaluates a request's access level for a given endpoint method.

This evaluator determines whether a requestor has access to a specific method or resource. Requestors may have fixed access levels, such as Admin for API owners and administrators, or variable access levels based on the resources being accessed.

For example, a user accessing their own resources may be assigned ResourceOwner access, while accessing another user's resources might result in AuthenticatedRequestor or even NoAccess, depending on the restrictions.

To implement more granular control (e.g., banning users, handling bots, or managing authenticated access), subclass this class and implement specific methods like:

  • isDeniedRequestor: Deny access to certain requestors (e.g., banned users).
  • isAuthenticatedRequestor: Validate if a requestor is authenticated.
  • isInternalRequestor: Identify if a requestor is an internal user or admin.

Note: If your API methods have characteristics like Internal, Moderative, or Institutional, you must implement the corresponding methods to evaluate these characteristics correctly. Otherwise, requestors will be assumed not to have the required access.

Constructors

Methods

  • Determines whether a requestor is denied access.

    This method can be overwritten to deny access to certain requestors, e.g., banned users, bots, users with expired / invalid tokens.

    This method can be used to require anything from requestors, e.g., authentication. You can decide what are the absolute minimum requirements to access your API.

    Type Parameters

    Parameters

    Returns boolean | Promise<boolean>

    A boolean that determines whether the requestor is denied access.