function respondWithAuthorizationFailure
Since 0.5.0
respondWithAuthorizationFailure(): void

Write the framework-standard response for an authorization refusal.

This keeps guards and decorator middleware byte-identical without coupling either plugin to the other's implementation. Every arm writes through respondWithError, so the refusal answers in whatever error format the application configured rather than a shape of this function's own.

The insufficient-privileges detail is deliberately fixed text: naming the role or permission a caller lacks tells an unauthorized caller what to acquire.

Parameters

The request context or response to write the refusal to

Which refusal to write

Return Type

void

Usage

import { respondWithAuthorizationFailure } from "common/src/index.ts";