Casbin Forum runs on Casnode, the open-source Discourse-style forum. Try the Casnode demo →
Casbin Forum

Hi, how to debug in casbin?

So I am getting False from the .enforce but I really don't know why. Using justmycode False and trying to debug, but the ast code is too hard to understand

image.png

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

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

[role_definition]
g = _, _, _

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

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

it should work clearly

3views
3users
2 minread

it's just pure code. learn to be a developer first

i just started yesterday so i have no idea,... although,... based on waht i know, you can try their online editor [https://casbin.org/editor/],.. seems like it can quickly show you how its gonna act/run... you can paste in the code then run the tests to see if its working as expected

Ya you are right . I went into the source code with vscode debugger and found out issue was that g function will take 3 arguments

Gemini sucks, it said me to pass two; while it did that, I wonder why there shouldn't be an error raised by casbin in such a case

Well sure, but I couldn't help myself with it

I will try more

But I think once I go into the source a few times I will get better insights and once I understand the ast that it makes, I will be able to debug all my issues

Its not a lot of code

well i hope it turns out well,.. if only i had a better standing on knowledge of it,.... however im still getting bamboozled,.. although it'll get away as i start implementing it,.. although auth is my weakness in coding,.,... RBAC is simpler although this time i need ABAC and its my first ABAC

I need to add the attribute based now

It is in the docs, but I need to implement that in order to see if that works for me

so maybe a day or 2 of focusing on that only might help,.. or reading their whitepaper might help to understand , its fairly not that big,, although the documentation might be better since its more finetuned for the situation at hand

aah ,. nice at least

One thing that I don't like about the docs it that the info about the g function is given in rbac page and it not highlighted enough to show it's importance

The g function is used across pages and one keeps scratching the head what it does

true,. i thought i was the only one who faound the documentation a bit vague,... well i thought its my skill issues on auth talking,... but yah its a bit of a pain

although can you use the ctrl+click to go to the source code and read about it maybe to get a better understanding

in your code editor that is

There are a lot of packages which link to the source code near some important concept

I ll try to make a pull request

1 / 12
Apr 2025