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

Hey, is it possible to match a subject name with wildcards like keyMatch2 does?

I would like to define a policy that applies to everyone.

#  sub                     dom          obj           act
p, role/chronicle.creator, chronicle/*, chronicle/*, create

# r.sub                    p.sub                   dom
g, user/*,                 role/chronicle.creator, chronicle/*
[request_definition]
r = sub, dom, obj, act

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

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

[role_definition]
g = _, _, _ 
# User to role mapping, with domain support

[matchers]
m = g(r.sub, p.sub, r.dom) && \
    keyMatch2(r.dom, p.dom) && \
    keyMatch2(r.obj, p.obj) && \
    (r.act == p.act || p.act == "*")

But obviously I can't just stick in keyMatch2 like I use for the other fields as I need the graph/grouping (g) to resolve for groups/roles

1views
2users
1 minread

I can't see anything that matches what I'm looking for, ie. glob matching users to groups

but maybe I'm just not well versed in reading the syntax yet

Any chance you could point out an example that allows assigning a group to users via. a wildcard (keyMatch, globMatch)?

That's the part I'm struggling with as that part is done via. the whole g graph side and I'm unsure that'd work

1 / 7
Aug 2025