fix: (rbac)
This commit is contained in:
parent
38f5c64153
commit
a1efff50f2
|
@ -98,13 +98,16 @@ func authorize(user Account) (m map[string]interface{}, err error) {
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
var roles []string
|
||||
for _, v := range user.Roles {
|
||||
roles = append(roles, v.Name)
|
||||
}
|
||||
m = util.MapStr{
|
||||
"access_token": tokenString,
|
||||
"username": user.Username,
|
||||
"id": user.ID,
|
||||
"expire_in": 86400,
|
||||
"roles": user.Roles,
|
||||
"roles": roles,
|
||||
"privilege": []string{
|
||||
"system.user:all", "system.role:all", "system.cluster:all", "system.command:all",
|
||||
},
|
||||
|
|
|
@ -21,6 +21,7 @@ const (
|
|||
)
|
||||
|
||||
type IRole interface {
|
||||
ListPermission() interface{}
|
||||
Create(localUser *User) (id string, err error)
|
||||
//Delete(localUser *User, id string) (err error)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package rbac
|
||||
|
||||
import (
|
||||
log "github.com/cihub/seelog"
|
||||
"infini.sh/console/internal/biz"
|
||||
httprouter "infini.sh/framework/core/api/router"
|
||||
"net/http"
|
||||
)
|
||||
|
@ -8,19 +10,19 @@ import (
|
|||
func (h Rbac) ListPermission(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||
typ := ps.MustGetParameter("type")
|
||||
|
||||
//err := biz.IsAllowRoleType(typ)
|
||||
//if err != nil {
|
||||
// h.Error400(w, err.Error())
|
||||
// return
|
||||
//}
|
||||
//role, err := biz.NewRole(typ)
|
||||
//
|
||||
//if err != nil {
|
||||
// _ = log.Error(err.Error())
|
||||
// h.Error(w, err)
|
||||
// return
|
||||
//}
|
||||
|
||||
h.WriteOKJSON(w, typ)
|
||||
err := biz.IsAllowRoleType(typ)
|
||||
if err != nil {
|
||||
h.Error400(w, err.Error())
|
||||
return
|
||||
}
|
||||
role, err := biz.NewRole(typ)
|
||||
|
||||
if err != nil {
|
||||
_ = log.Error(err.Error())
|
||||
h.Error(w, err)
|
||||
return
|
||||
}
|
||||
permissions := role.ListPermission()
|
||||
h.WriteOKJSON(w, permissions)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue