Skip to content

Commit

Permalink
feat: Use "casbin" command instead of "java -jar target/casbin-java-c…
Browse files Browse the repository at this point in the history
…li.jar" command
  • Loading branch information
liewstar committed Sep 18, 2024
1 parent e8a0881 commit f5972cf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,32 @@ mvn clean install
- Check whether Alice has read permission on data1

```shell
java -jar target/casbin-java-cli.jar -m "examples/rbac_model.conf" -p "examples/rbac_policy.csv" -e "alice, data1, read"
./casbin.sh -m "examples/rbac_model.conf" -p "examples/rbac_policy.csv" -e "alice, data1, read"
```
> Allow
```shell
java -jar target/casbin-java-cli.jar -m "[request_definition]|r = sub, obj, act|[policy_definition]|p = sub, obj, act|[role_definition]|g = _, _|[policy_effect]|e = some(where (p.eft == allow))|[matchers]|m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act" -p "p, alice, data1, read|p, bob, data2, write|p, data2_admin, data2, read|p, data2_admin, data2, write|g, alice, data2_admin" -e "alice, data1, read"
./casbin.sh -m "[request_definition]|r = sub, obj, act|[policy_definition]|p = sub, obj, act|[role_definition]|g = _, _|[policy_effect]|e = some(where (p.eft == allow))|[matchers]|m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act" -p "p, alice, data1, read|p, bob, data2, write|p, data2_admin, data2, read|p, data2_admin, data2, write|g, alice, data2_admin" -e "alice, data1, read"
```
> Allow

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

```shell
java -jar target/casbin-java-cli.jar -m "examples/rbac_model.conf" -p "examples/rbac_policy.csv" -ex "alice, data2, write"
./casbin.sh -m "examples/rbac_model.conf" -p "examples/rbac_policy.csv" -ex "alice, data2, write"
```
> true Reason: [alice, data2, write]

- Add a policy to the policy file

```shell
java -jar target/casbin-java-cli.jar -m "examples/rbac_model.conf" -p "examples/rbac_policy.csv" -ap "alice, data2, write"
./casbin.sh -m "examples/rbac_model.conf" -p "examples/rbac_policy.csv" -ap "alice, data2, write"
```
> Add Success

- Delete a policy from the policy file

```shell
java -jar target/casbin-java-cli.jar -m "examples/rbac_model.conf" -p "examples/rbac_policy.csv" -rp "alice,data1,read"
./casbin.sh -m "examples/rbac_model.conf" -p "examples/rbac_policy.csv" -rp "alice,data1,read"
```
> Remove Success

5 changes: 5 additions & 0 deletions casbin.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@echo off
setlocal
set JAR_PATH=target\casbin-java-cli.jar
java -jar "%JAR_PATH%" %*
endlocal
2 changes: 2 additions & 0 deletions casbin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
java -jar target/casbin-java-cli.jar "$@"

0 comments on commit f5972cf

Please sign in to comment.