(req: express.Request, _?: express.Response, next?: express.NextFunction)
| 340 | * Throw a forbidden error if origin checks fail. Call `next` if provided. |
| 341 | */ |
| 342 | export function ensureOrigin(req: express.Request, _?: express.Response, next?: express.NextFunction): void { |
| 343 | try { |
| 344 | authenticateOrigin(req) |
| 345 | if (next) { |
| 346 | next() |
| 347 | } |
| 348 | } catch (error) { |
| 349 | logger.debug(`${error instanceof Error ? error.message : error}; blocking request to ${req.originalUrl}`) |
| 350 | throw new HttpError("Forbidden", HttpCode.Forbidden) |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | /** |
| 355 | * Return true if the origin matches any trusted origin. Entries are matched |
no test coverage detected