Skip to content

Commit

Permalink
fix: use delete permission as admin check in group
Browse files Browse the repository at this point in the history
Signed-off-by: Kush Sharma <thekushsharma@gmail.com>
  • Loading branch information
kushsharma committed Oct 5, 2023
1 parent c57d8f4 commit fee240d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions core/group/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const (
Disabled State = "disabled"

MemberPermission = schema.MembershipPermission
AdminPermission = schema.DeletePermission
)

type Repository interface {
Expand Down
13 changes: 8 additions & 5 deletions pkg/server/interceptors/authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"errors"
"fmt"

"github.com/raystack/frontier/core/group"

"github.com/raystack/frontier/pkg/server/health"

"github.com/raystack/frontier/internal/api/v1beta1"
Expand Down Expand Up @@ -418,12 +420,13 @@ var authorizationValidationMap = map[string]func(ctx context.Context, handler *v
return err
}

if ns == schema.OrganizationNamespace {
return handler.IsAuthorized(ctx, schema.OrganizationNamespace, id, schema.PolicyManagePermission)
} else if ns == schema.GroupNamespace {
return handler.IsAuthorized(ctx, schema.GroupNamespace, id, schema.UpdatePermission)
switch ns {
case schema.OrganizationNamespace, schema.ProjectNamespace:
return handler.IsAuthorized(ctx, ns, id, schema.PolicyManagePermission)
case schema.GroupNamespace:
return handler.IsAuthorized(ctx, ns, id, group.AdminPermission)
}
return handler.IsAuthorized(ctx, schema.ProjectNamespace, id, schema.PolicyManagePermission)
return handler.IsAuthorized(ctx, ns, id, schema.DeletePermission)
},
"/raystack.frontier.v1beta1.FrontierService/GetPolicy": func(ctx context.Context, handler *v1beta1.Handler, req any) error {
return nil
Expand Down

0 comments on commit fee240d

Please sign in to comment.