Page MenuHomeSealhub

match-policy.ts
No OneTemporary

match-policy.ts

import type { Middleware } from "@koa/router";
import type Policy from "../chip-types/policy.js";
export default function MatchPolicy(policy: Policy): Middleware {
return async function (ctx, next) {
const result = await policy.check(ctx.$context);
if (!result) {
ctx.body = "Not allowed";
ctx.status = 403;
return;
}
if (!result.allowed) {
ctx.body = result.reason;
ctx.status = 403;
}
if (result.allowed) await next();
};
}

File Metadata

Mime Type
text/x-java
Expires
Fri, Jan 24, 15:16 (13 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
601151
Default Alt Text
match-policy.ts (456 B)

Event Timeline