Add namespace.manage permission rule
UI needs to know if user can access admin pages and manage specific namespace Administrators (role) get this permission in the preset
This commit is contained in:
@@ -64,6 +64,10 @@ func (svc accessControl) CanDeleteNamespace(ctx context.Context, r *types.Namesp
|
||||
return svc.can(ctx, r, "delete")
|
||||
}
|
||||
|
||||
func (svc accessControl) CanManageNamespace(ctx context.Context, r *types.Namespace) bool {
|
||||
return svc.can(ctx, r, "manage")
|
||||
}
|
||||
|
||||
func (svc accessControl) CanCreateModule(ctx context.Context, r *types.Namespace) bool {
|
||||
return svc.can(ctx, r, "module.create")
|
||||
}
|
||||
@@ -194,6 +198,7 @@ func (svc accessControl) DefaultRules() permissions.RuleSet {
|
||||
allowAdm(namespaces, "read"),
|
||||
allowAdm(namespaces, "update"),
|
||||
allowAdm(namespaces, "delete"),
|
||||
allowAdm(namespaces, "manage"),
|
||||
allowAdm(namespaces, "page.create"),
|
||||
allowAdm(namespaces, "module.create"),
|
||||
allowAdm(namespaces, "chart.create"),
|
||||
@@ -236,6 +241,7 @@ func (svc accessControl) Whitelist() permissions.Whitelist {
|
||||
"read",
|
||||
"update",
|
||||
"delete",
|
||||
"manage",
|
||||
"module.create",
|
||||
"chart.create",
|
||||
"trigger.create",
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/cortezaproject/corteza-server/compose/internal/repository"
|
||||
"github.com/cortezaproject/corteza-server/compose/types"
|
||||
"github.com/cortezaproject/corteza-server/internal/permissions"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -26,6 +27,8 @@ type (
|
||||
CanReadNamespace(context.Context, *types.Namespace) bool
|
||||
CanUpdateNamespace(context.Context, *types.Namespace) bool
|
||||
CanDeleteNamespace(context.Context, *types.Namespace) bool
|
||||
|
||||
Grant(ctx context.Context, rr ...*permissions.Rule) error
|
||||
}
|
||||
|
||||
NamespaceService interface {
|
||||
@@ -92,6 +95,7 @@ func (svc namespace) Find(filter types.NamespaceFilter) (set types.NamespaceSet,
|
||||
return
|
||||
}
|
||||
|
||||
// Create adds namespace and presets access rules for role everyone
|
||||
func (svc namespace) Create(mod *types.Namespace) (*types.Namespace, error) {
|
||||
if !svc.ac.CanCreateNamespace(svc.ctx) {
|
||||
return nil, ErrNoCreatePermissions.withStack()
|
||||
|
||||
@@ -17,6 +17,7 @@ type (
|
||||
CanGrant bool `json:"canGrant"`
|
||||
CanUpdateNamespace bool `json:"canUpdateNamespace"`
|
||||
CanDeleteNamespace bool `json:"canDeleteNamespace"`
|
||||
CanManageNamespace bool `json:"canManageNamespace"`
|
||||
CanCreateModule bool `json:"canCreateModule"`
|
||||
CanCreateChart bool `json:"canCreateChart"`
|
||||
CanCreateTrigger bool `json:"canCreateTrigger"`
|
||||
@@ -37,6 +38,7 @@ type (
|
||||
CanGrant(context.Context) bool
|
||||
|
||||
CanUpdateNamespace(context.Context, *types.Namespace) bool
|
||||
CanManageNamespace(context.Context, *types.Namespace) bool
|
||||
CanDeleteNamespace(context.Context, *types.Namespace) bool
|
||||
|
||||
CanCreateModule(context.Context, *types.Namespace) bool
|
||||
@@ -119,6 +121,7 @@ func (ctrl Namespace) makePayload(ctx context.Context, ns *types.Namespace, err
|
||||
CanGrant: ctrl.ac.CanGrant(ctx),
|
||||
CanUpdateNamespace: ctrl.ac.CanUpdateNamespace(ctx, ns),
|
||||
CanDeleteNamespace: ctrl.ac.CanDeleteNamespace(ctx, ns),
|
||||
CanManageNamespace: ctrl.ac.CanManageNamespace(ctx, ns),
|
||||
|
||||
CanCreateModule: ctrl.ac.CanCreateModule(ctx, ns),
|
||||
CanCreateChart: ctrl.ac.CanCreateChart(ctx, ns),
|
||||
|
||||
Reference in New Issue
Block a user