Access Control: Move database-related models to enterprise (#32907)

* Move database-related models to enterprise

* Chore: use GetUserBuiltInRoles() method

* Rename permission to action
This commit is contained in:
Alexander Zobnin
2021-04-13 16:28:11 +03:00
committed by GitHub
parent bd74953f0d
commit 7ea58f9cf5
5 changed files with 29 additions and 48 deletions
+4 -28
View File
@@ -4,12 +4,9 @@ import (
"time"
)
// Role is the model for Role in RBAC.
type Role struct {
ID int64 `json:"id" xorm:"pk autoincr 'id'"`
OrgID int64 `json:"orgId" xorm:"org_id"`
Version int64 `json:"version"`
UID string `xorm:"uid" json:"uid"`
UID string `json:"uid"`
Name string `json:"name"`
Description string `json:"description"`
@@ -18,33 +15,16 @@ type Role struct {
}
type RoleDTO struct {
ID int64 `json:"id" xorm:"pk autoincr 'id'"`
OrgID int64 `json:"orgId" xorm:"org_id"`
Version int64 `json:"version"`
UID string `xorm:"uid" json:"uid"`
UID string `json:"uid"`
Name string `json:"name"`
Description string `json:"description"`
Permissions []Permission `json:"permissions,omitempty"`
Updated time.Time `json:"updated"`
Created time.Time `json:"created"`
}
// Permission is the model for Permission in RBAC.
type Permission struct {
ID int64 `json:"id" xorm:"pk autoincr 'id'"`
RoleID int64 `json:"-" xorm:"role_id"`
Permission string `json:"permission"`
Scope string `json:"scope"`
Updated time.Time `json:"updated"`
Created time.Time `json:"created"`
}
type GetUserPermissionsQuery struct {
OrgID int64 `json:"-"`
UserID int64 `json:"userId"`
Roles []string
Action string `json:"action"`
Scope string `json:"scope"`
}
type EvaluationResult struct {
@@ -54,11 +34,7 @@ type EvaluationResult struct {
func (p RoleDTO) Role() Role {
return Role{
ID: p.ID,
OrgID: p.OrgID,
Name: p.Name,
Description: p.Description,
Updated: p.Updated,
Created: p.Created,
}
}