Skip to content

TypeScript API / laikacms/json-api / AuthorizeDecision

Type Alias: AuthorizeDecision ​

ts
type AuthorizeDecision = boolean | LaikaError;

The verdict an authorization callback returns for a single API action:

  • true — allow the action.
  • false — deny it with a generic ForbiddenError (HTTP 403).
  • a LaikaError — deny it with that specific error, so callers can customise the status/message (e.g. return an AuthenticationError for a missing token → 401, or a bespoke ForbiddenError with a reason).

Callbacks may return the decision synchronously or as a Promise (e.g. when they need to look up a token in a database).

Released under the MIT License.