casbin / node-casbin

An authorization library that supports access control models like ACL, RBAC, ABAC in Node.js and Browser

Home Page:https://casbin.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to get user all permissions

RogersLei opened this issue · comments

Background
Node-casbin: 5.30.0

Want to get user permissions in resource with implicit use getImplicitResourcesForUser('alice') or getImplicitPermissionsForUser('alice') to get alice permissions in data2, but both are only return [[alice, data1, ALL, 15]]

Model

[request_definition]
r = sub, obj, attr, act

[policy_definition]
p = sub, obj, attr, act

[role_definition]
g = _, _
g2 = _, _

[policy_effect]
e = some(where (p.eft == allow))

[matchers]
m = g(r.sub, p.sub) && g2(r.obj, p.obj) && r.attr == p.attr && r.act == p.act

Policy

p, alice, data1, ALL, 15

g2, data1, data2
g2, data2, data1

Request
alice, data2, ALL, 15

Result
true

This example in editor is worked, but in code can't get permissions with data2.

Expected

[[alice, data1, ALL, 15], [alice, data2, ALL, 15]]

Hello, can anyone help ? Thanks!