feat: add CI workflows (#7)

4 files changed
tree: 7d1b418755aeaf4e1314a2fb06f9902fadf2ff63
  1. .github/
  2. examples/
  3. src/
  4. .gitignore
  5. .releaserc.json
  6. LICENSE
  7. pom.xml
  8. 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