New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getAllNamedRoles returning null #38
Comments
Can you provide model conf. |
@lucaslrolim We have added some tests here: 43e2654 . And it shows |
@nodece [request_definition]
r = sub, obj, dom, act
[policy_definition]
p = sub, obj, dom, 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) && (regexMatch(r.dom, p.dom) || r.dom === '') && (regexMatch(r.act, p.act) || p.act === 'all') @hsluoyz I'm using |
dev envnode: v8.11.2 simple testasync function test() {
const modelText = `
[request_definition]
r = sub, obj, dom, act
[policy_definition]
p = sub, obj, dom, 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) && (regexMatch(r.dom, p.dom) || r.dom === '') && (regexMatch(r.act, p.act) || p.act === 'all')
`;
const m = newModel(modelText);
const e = await newEnforcer(m);
await e.addNamedGroupingPolicy('g', 'test_role', 'admin');
await e.addNamedGroupingPolicy('g', 'sub_role_test1', 'test_role');
await e.addNamedGroupingPolicy('g', 'sub_role_test2', 'test_role');
await e.addNamedGroupingPolicy('g', 'sub_role_test2', 'test_role');
await e.addNamedGroupingPolicy('g', 'test_role_2', 'admin');
await e.addNamedGroupingPolicy('g', 'user_test', 'just_test_role');
await e.addNamedGroupingPolicy('g2', 'glosas', 'plataforma');
await e.addNamedGroupingPolicy('g2', 'credentials', 'plataforma');
const g = e.getAllNamedRoles('g');
console.log(g, g.length !== 0 && g.some(n => n === 'admin'));
const g2 = e.getAllNamedRoles('g2');
console.log(g2, g2.length !== 0 && g2.some(n => n === 'plataforma'));
} print result
You can try using the above test :) |
@lucaslrolim |
I have implemented these two methods:
And some of my policies are:
In both methods the result is null. Is this a bug?
The text was updated successfully, but these errors were encountered: