如何使用Casbin与Beego设置动态RBAC?

How do I setup dynamic RBAC using Casbin with Beego? I am using MySQL database via Beego ORM and able to login. However, I want to setup roles and permissions.

I also explored gorbac but I am interested to use Casbin.

There's an authorization middleware for Beego here: https://github.com/casbin/beego-authz. You can read the README.md to know how to do it. And for your requirement:

  1. Please use the Xorm Adapter or Gorm Adapter to store Casbin policy into MySQL. We also have Beego ORM Adapter but it has some limitations.

  2. You want to setup roles, so you can use Casbin's RBAC model. You can start with the official RBAC example (model + policy). If your resource is just the RESTful path, you can also refer to the RESTful example.