Skip to content
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

enforce error #154

Open
transtone opened this issue Dec 12, 2023 · 2 comments
Open

enforce error #154

transtone opened this issue Dec 12, 2023 · 2 comments
Assignees
Labels

Comments

@transtone
Copy link

transtone commented Dec 12, 2023

there is a error when use keymatch4 in model.conf

[request_definition]
r = sub, obj, act

[policy_definition]
p = sub, obj, act

[role_definition]
g = _, _

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

[matchers]
m = g(r.sub, p.sub) && keyMatch4(r.obj, p.obj) && regexMatch(r.act, p.act)
local Enforcer = require("casbin")

local e = Enforcer:new("/opt/openresty/nginx/conf/lua/casbin/rbac_model.conf", "/opt/openresty/nginx/conf/lua/casbin/examples/rbac_policy.csv")

local cjson = require "cjson"
local response = {}

local sub = "alice" -- the user that wants to access a resource.
local obj = "data1" -- the resource that is going to be accessed.
local act = "read" -- the operation that the user performs on the resource.

if e:enforce(sub, obj, act) then
  response['code'] = 200
  response['result'] = true
  response['msg'] = e:GetPolicy()
  ngx.say(cjson.encode(response))
end
2023/12/12 18:42:33 [error] 208585#0: *4 lua entry thread aborted: runtime error: 
...openresty/luajit/share/lua/5.1/src/main/CoreEnforcer.lua:449: attempt to concatenate field 'message' (a nil value)
stack traceback:
coroutine 0:
        ...openresty/luajit/share/lua/5.1/src/main/CoreEnforcer.lua: in function 'enforceEx'
        ...openresty/luajit/share/lua/5.1/src/main/CoreEnforcer.lua:534: in function 'enforce'
@casbin-bot
Copy link
Member

@Edmond-J-A @rushitote @techoner

@hsluoyz
Copy link
Member

hsluoyz commented Dec 20, 2023

@transtone it seems that your error doesn't match with your source code, the error shows enforceEx and a field called message, but your code never mentioned those. So why is that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

3 participants