func deleteHandler(ctx *possum.Context) error { name := ctx.Request.Form.Get("name") role := rbac.Get(name) rbac.Remove(name) ctx.Response.Data = gorbac.RoleToMap(role) return nil }
func (rbac *myRbac) Patch(w http.ResponseWriter, r *http.Request) (status int, data interface{}) { name := r.Form.Get("name") permissions := r.Form["permissions"] parents := r.Form["parents"] rbac.Rbac.Add(name, permissions, parents) return http.StatusOK, gorbac.RoleToMap(rbac.Rbac.Get(name)) }
func (rbac *myRbac) Get(w http.ResponseWriter, r *http.Request) (status int, data interface{}) { name := r.Form.Get("name") if name == "" { return http.StatusOK, rbac.Rbac.Dump() } return http.StatusOK, gorbac.RoleToMap(rbac.Rbac.Get(name)) }
func patchHandler(ctx *possum.Context) error { name := ctx.Request.Form.Get("name") permissions := ctx.Request.Form["permissions"] parents := ctx.Request.Form["parents"] rbac.Add(name, permissions, parents) ctx.Response.Data = gorbac.RoleToMap(rbac.Get(name)) return nil }
func isGranded(w http.ResponseWriter, r *http.Request) (status int, data interface{}) { name := r.Form.Get("name") permission := r.Form.Get("permission") if rbac.Rbac.IsGranted(name, permission, nil) { return http.StatusOK, gorbac.RoleToMap(rbac.Rbac.Get(name)) } return http.StatusForbidden, nil }
func getHandler(ctx *possum.Context) error { name := ctx.Request.Form.Get("name") if name == "" { ctx.Response.Data = rbac.Dump() } else { ctx.Response.Data = gorbac.RoleToMap(rbac.Get(name)) } return nil }
func (rbac *myRbac) Delete(w http.ResponseWriter, r *http.Request) (status int, data interface{}) { name := r.Form.Get("name") role := rbac.Rbac.Get(name) rbac.Rbac.Remove(name) return http.StatusOK, gorbac.RoleToMap(role) }