Go CLI for Casbin

Clone this repo:
  1. bd1ccd6 feat: add JSON parsing support while keeping regex {field:value} (#21) by FAUST. · 6 months ago master v1.12.0
  2. bffe404 feat: upgrade casbin to v2.116.0 to support BLP (Bell-LaPadula) model (#20) by yxrxy · 7 months ago v1.11.0
  3. 96f693c feat: improve version print by hsluoyz · 1 year, 2 months ago v1.10.0
  4. 36a6791 feat: support "-v/--version" to get version of casbin-go-cli (#19) by Liao Xin · 1 year, 2 months ago v1.9.0
  5. 50ecee2 feat: support "ABAC" model (#17) by Liao Xin · 1 year, 2 months ago v1.8.0

casbin-go-cli

Go Report Card Build Coverage Status Godoc Release Discord

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
git clone https://github.com/casbin/casbin-go-cli.git
  1. Build project
cd casbin-go-cli
go build -o casbin

Options

optionsdescriptionmust
-m, --modelThe path of the model file or model texty
-p, --policyThe path of the policy file or policy texty
enforceCheck permissionsn
enforceExCheck permissions and get which policy it isn

Get started

  • Check whether Alice has read permission on data1

    ./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)

    ./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)

    ./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”]}