casbin / jcasbin

An authorization library that supports access control models like ACL, RBAC, ABAC in Java
https://casbin.org
Apache License 2.0
2.4k stars 464 forks source link

Custom field name for policy effect #102

Closed anhldbk closed 4 years ago

anhldbk commented 4 years ago

Hi there,

I see an error while customizing policy model

# Here I use `effect` instead of `eft`
[policy_definition]
p = subject, object, act, effect

Here what the error looks like:

Screen Shot 2020-10-09 at 18 20 36

If I modify effect back to eft, everything works normally.

Would you please tell me is this an intended behaviour?

Thank you.

hsluoyz commented 4 years ago

@anhldbk hi, you are sending to the wrong place. Please send online editor related questions to: https://github.com/casbin/casbin-editor

anhldbk commented 4 years ago

@hsluoyz Diving into jcasbin code base, I've found following logic

    public boolean mergeEffects(String expr, Effect[] effects, float[] results) {
        boolean result;
        if (expr.equals("some(where (p_eft == allow))")) {
            result = false;
            for (Effect eft : effects) {
                if (eft == Effect.Allow) {
                    result = true;
                    break;
                }
            }
        }
        //
    }

Looks like it's hard coded into the implementation.