@adonis-agora/authz
弹幕集成, DB 后置 非洲区域局 页:1 阿多尼斯·贾克 角色,权限, 顶部的通配符匹配和多租借
@adonisjs/bouncer, (中文(简体) ), 有可插件商店。 部分 阿戈拉语Name 生态系统.
没错 没有 替换 Bouncer — 它记录了一小组静态 Buncer
能力(can, (中文(简体) ), hasRole其机构查阅数据库支持的许可
存储。 你继续使用 ctx.bouncer.allows(...) 财务报告和审定财务报表 @can(...) 跟你一样
今天来.
安装
npm i @adonis-agora/authz
node ace configure @adonis-agora/authz
node ace migration:run # if you use the Lucid store
使用
// app/abilities/authz.ts was published for you:
import { can, hasRole } from '#abilities/authz'
// In a controller / route:
await ctx.bouncer.allows('can', 'posts.edit', post) // wildcard: posts.* ⊇ posts.edit
await ctx.bouncer.authorize('hasRole', 'admin')
@can('can', 'posts.edit')
<a href="/posts/{{ post.id }}/edit">Edit</a>
@end
国家行动倡议或方案的赠款:
node ace authz:grant editor posts.edit
node ace authz:assign editor 42
需要了解资源 否认 从外部政策引擎? 插头a
decisionProvider 输入 config/authz.ts - Cerbos适配船,位于
@adonis-agora/authz/cerbos (没有额外的运行时间依赖;带自己的
@cerbos/http 客户端). 超高级验收后就开机了
authz.canMany,并将 Cerbos 查询计划映射到 accessibleBy 瞄准镜.
见 文档 概念( wildcards, 租赁), 配置驱动程序 Lucid mixin, Ace命令和测试.
盘子
authorizeByRoles({ roles: ['ADMIN'] }) 这是 authorize 钩子
@adonis-agora 仪表板(望远镜、耐用、介质、付款、代理)。 这个
返回一个 AuthorizeResult数字 : true,或 { allowed: false, reason: 'unauthenticated' | 'forbidden' } 所以仪表板可以回答 401 对 403。 。 。 .
需要接受的仪表板 lib 版本
AuthorizeDecision。 。 。 . 这个 拒绝是一个对象( 真实性); 一个更古老的将结果当作 布尔会让它通过。 见最小版本docs/middleware.mdx。 。 。 .
许可证
麻省理工学院