feat: add README (#5)

* feat: Initialize cli usage

* feat: add removePolicy and addPolicy

* feat: delete before client

* feat: modify class name

* feat: add readme
1 file changed
tree: b67836c341830105794bb2cbe871d131458af37a
  1. examples/
  2. src/
  3. .gitignore
  4. LICENSE
  5. pom.xml
  6. README.md
README.md

casbin-java-cli

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

optionsdescriptionmust
-m, --modelThe path of the model filey
-p, --policyThe path of the policy filey
-e, --enforceCheck permissionsn
-ex, --enforceExCheck permissions and get which policy it isn
-ap, --addPolicyAdd a policy rule to the policy filen
-rp, --removePolicyRemove a policy rule from the policy filen

Get started

  • Check whether Alice has read permission on data1

    java -jar target/casbin-java-cli.jar -m examples/rbac_model.conf -p examples/rbac_policy.csv -e alice,data1,read
    

    Allow

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

    java -jar target/casbin-java-cli.jar -m examples/rbac_model.conf -p examples/rbac_policy.csv -ex alice,data2,write
    

    EnforceResult{allow=true, explain=[data2_admin, data2, write]}

  • Add a policy to the policy file

    java -jar target/casbin-java-cli.jar -m examples/rbac_model.conf -p examples/rbac_policy.csv -ap alice,data2,write
    

    Add Success

  • Delete a policy from the policy file

    java -jar target/casbin-java-cli.jar -m examples/rbac_model.conf -p examples/rbac_policy.csv -rp alice,data1,read
    

    Remove Success