示例#1
0
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
}
示例#2
0
文件: http.go 项目: iwarsong/bearded
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))
}
示例#3
0
文件: http.go 项目: iwarsong/bearded
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))
}
示例#4
0
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
}
示例#5
0
文件: http.go 项目: iwarsong/bearded
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
}
示例#6
0
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
}
示例#7
0
文件: http.go 项目: iwarsong/bearded
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)
}