Skip to content
buffalo cashbin-based rbac middleware
Branch: master
Clone or download
Latest commit 810df2a Jan 28, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
README.md
rbac.go
rbac_model.conf
rbac_policy.csv add tests Jan 2, 2019
rbac_test.go add tests Jan 2, 2019

README.md

buffalo-mw-rbac

Installation

$ go get -u github.com/kgosse/buffalo-mw-rbac

Usage

// setup casbin auth rules
authEnforcer, err := casbin.NewEnforcerSafe("rbac_model.conf", "rbac_policy.csv")
if err != nil {
  log.Fatal(err)
}
roleFunc := func(c buffalo.Context) (string, error) {
  // implement your logic to get user's role
  role := "anonymous"
  return role, nil
}
app.Use(rbac.New(authEnforcer, roleFunc))

If you want a real example, check this project: https://github.com/kgosse/shop-back

You can’t perform that action at this time.