Koa-OAI-Router-ACL
ACL plugin koa-oai-router
Installation
npm i koa-oai-router-acl --save
Info
field | type | info |
---|---|---|
name | string |
acl |
evoked fields | string |
x-oai-acl |
evoked fileds value | object |
{resource,permission} |
options | object |
acl , getUid , before , after |
options
{object}
acl
{function}
acl factory function. having args(Acl)
and must return a acl instance.getUid
{function}
get uid. having args(ctx)
and must return a uid({string}
).before
{function}
handle before acl permission test. having args(ctx, next)
,next
evoked will allow request.after
{function}
handle after acl permission test. having args(ctx, next, allowed)
.
const Koa = ;const Router = ;const MiddlewarePlugin = ;const AclPlugin = ;const Redis = ; const app = ;const router = apiDoc: './api' options: MiddlewarePlugin: './controllers' AclPlugin: acl: async { const redis = keyPrefix: 'acl_test' ; await { redis; redis; }; return redis; } { // you uid code. return ctxsessionuserId; } ; router;router; app;