casbin_example
casbin_example copied to clipboard
We may need a sample request for beginner
This repository is so helpful to understand casbin works under the gin web application. But, there are no sample requests to feel RBAC. So I wrote a tiny snippet for beginner. You can adapt it into README
, if you like it.
-
Login as Bob
curl -c cookie.txt -d "username=bob" -d "password=123" "http://localhost:8081/user/login"
-
Read resource
curl -b cookie.txt http://localhsot:8081/api/resource
You can get a following output
{“code”:1,“message”:“read resource successfully”,“data”:“resource”}
-
Write resource
curl -XPOST -b cookie.txt localhost:8081/api/resource
You can be denied a request because of the defined policy
{“code”:0,“message”:“forbidden”,“data”:null}