https://github.com/casbin/casbin-go-cli
Go CLI for Casbin
https://github.com/casbin/casbin-go-cli
abac acl auth authorization authz casbin cli go golang rbac
Last synced: 9 months ago
JSON representation
Go CLI for Casbin
- Host: GitHub
- URL: https://github.com/casbin/casbin-go-cli
- Owner: casbin
- License: apache-2.0
- Created: 2024-07-10T15:38:24.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-01-15T12:46:29.000Z (12 months ago)
- Last Synced: 2025-04-06T02:23:15.133Z (9 months ago)
- Topics: abac, acl, auth, authorization, authz, casbin, cli, go, golang, rbac
- Language: Go
- Homepage: https://casbin.org
- Size: 39.1 KB
- Stars: 1
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# casbin-go-cli
[](https://goreportcard.com/report/github.com/casbin/casbin-go-cli)
[](https://github.com/casbin/casbin-go-cli/actions/workflows/build.yml)
[](https://coveralls.io/github/casbin/casbin-go-cli?branch=master)
[](https://pkg.go.dev/github.com/casbin/casbin-go-cli)
[](https://github.com/casbin/casbin-go-cli/releases/latest)
[](https://discord.gg/S5UjpzGZjN)
casbin-go-cli is a command-line tool based on Casbin (Go language), enabling you to use all of Casbin APIs in the shell.
## Installation
1. Clone project from repository
```shell
git clone https://github.com/casbin/casbin-go-cli.git
```
2. Build project
```shell
cd casbin-go-cli
go build -o casbin
```
## Options
| options | description | must |
|----------------|----------------------------------------------|------|
| `-m, --model` | The path of the model file or model text | y |
| `-p, --policy` | The path of the policy file or policy text | y |
| `enforce` | Check permissions | n |
| `enforceEx` | Check permissions and get which policy it is | n |
## Get started
- Check whether Alice has read permission on data1
```shell
./casbin enforce -m "test/basic_model.conf" -p "test/basic_policy.csv" "alice" "data1" "read"
```
> {"allow":true,"explain":[]}
- Check whether Alice has write permission for data1 (with explanation)
```shell
./casbin enforceEx -m "test/basic_model.conf" -p "test/basic_policy.csv" "alice" "data1" "write"
```
> {"allow":false,"explain":[]}
- Check whether Alice has read permission on data1 in domain1 (with explanation)
```shell
./casbin enforceEx -m "test/rbac_with_domains_model.conf" -p "test/rbac_with_domains_policy.csv" "alice" "domain1" "data1" "read"
```
> {"allow":true,"explain":["admin","domain1","data1","read"]}