Java CLI for jCasbin

Clone this repo:
  1. f05dfad feat: add smart type conversion for Object[] parameters (#44) by FAUST. · 6 months ago master v1.17.0
  2. b57bef6 feat: optimize exception handling (#43) by Liao Xin · 1 year, 2 months ago v1.16.0
  3. c3612e9 feat: show better error message (#42) by Liao Xin · 1 year, 2 months ago v1.15.0
  4. 623968c feat: fix "ABAC" model enforceEx error (#40) by Liao Xin · 1 year, 2 months ago v1.14.0
  5. cb0fa09 docs: add badges to README like other repos (#39) by sukidayou · 1 year, 2 months ago

casbin-java-cli

build codecov Release Discord

casbin-java-cli is a command-line tool based on jcasbin, enabling you to use all of jcasbin's APIs in the shell.

Installation

  1. Clone project from repository
git clone https://github.com/jcasbin/casbin-java-cli.git
  1. Build project, the jar package will be generated in the target directory
cd casbin-java-cli
mvn clean install

Options

optionsdescriptionmustremark
-m, --modelThe path of the model file or model textyPlease wrap it with "" and separate each line with |
-p, --policyThe path of the policy file or policy textyPlease wrap it with "" and separate each line with |
-e, --enforceCheck permissionsnPlease wrap it with ""
-ex, --enforceExCheck permissions and get which policy it isnPlease wrap it with ""
-AF, --addFuntionAdd custom funtionnPlease wrap it with "" and separate each line with |
-ap, --addPolicyAdd a policy rule to the policy filenPlease wrap it with ""
-rp, --removePolicyRemove a policy rule from the policy filenPlease wrap it with ""

Get started

  • Check whether Alice has read permission on data1

    ./casbin enforce -m "examples/rbac_model.conf" -p "examples/rbac_policy.csv" "alice" "data1" "read"
    

    {“allow”:true,“explain”:null}

    ./casbin enforce -m "[request_definition]\nr = sub, obj, act\n[policy_definition]\np = sub, obj, act\n[role_definition]\ng = _, _\n[policy_effect]\ne = some(where (p.eft == allow))\n[matchers]\nm = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act" -p "p, alice, data1, read\np, bob, data2, write\np, data2_admin, data2, read\np, data2_admin, data2, write\ng, alice, data2_admin" "alice" "data1" "read"
    

    {“allow”:true,“explain”:null}

  • Check whether Alice has write permission for data2. If so, display the effective policy.

    ./casbin enforceEx -m "examples/rbac_model.conf" -p "examples/rbac_policy.csv" "alice" "data2" "write"
    

    {“allow”:true,“explain”:[“data2_admin”,“data2”,“write”]}

  • Add a policy to the policy file

    ./casbin addPolicy -m "examples/rbac_model.conf" -p "examples/rbac_policy.csv" "alice" "data2" "write"
    

    {“allow”:true,“explain”:null}

  • Delete a policy from the policy file

    ./casbin removePolicy -m "examples/rbac_model.conf" -p "examples/rbac_policy.csv" "alice" "data2" "write"
    

    {“allow”:true,“explain”:null}