A middleware for request validation created with Go and Vault
- Run Vault Service
- Run Profile & Role Service
- Run Account Microservice
go get -u github.com/ExponentialEducation/go-rbac
Middleware can be added to a router using Router.Use()
:
// package main
import "github.com/ExponentialEducation/go-rbac"
func main() {
r := mux.NewRouter()
r.HandleFunc("/v1/example", handlerFunc).Methods("POST")
// Config
rbac := rbac.RBAC{
VaultAPI: "http://127.0.0.1:8200",
Username: "authorizer",
Password: "helloworld",
FirebaseCert: "firebase-admin.json",
RoleAPI: "http://127.0.0.1:8080",
}
if err := rbac.Initialize(); err != nil {
fmt.Println(err.Error())
}
r.Use(rbac.Authorizer())
if err := http.ListenAndServe(":5000", r); err != nil {
fmt.Println(err)
}
}
For more information Example directory