Relocate agent-run authorization to its package
The agent-run actions and policies lived in the core probo policy set, which forced every authorization change for the agent-run domain to touch unrelated core files. Move the actions and the OWNER/ADMIN and VIEWER/AUDITOR policies into the agentrun package and have it expose a PolicySet that probod registers into the authorizer at composition time, so the rules live alongside the domain logic they govern. Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"go.gearno.de/kit/log"
|
||||
"go.probo.inc/probo/pkg/agentrun"
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/iam"
|
||||
@@ -370,7 +371,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
return types.NewWebhookSubscription(wc), nil
|
||||
}
|
||||
case coredata.AgentRunEntityType:
|
||||
action = probo.ActionAgentRunGet
|
||||
action = agentrun.ActionAgentRunGet
|
||||
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||
run, err := r.agentRun.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"time"
|
||||
|
||||
"go.gearno.de/kit/log"
|
||||
"go.probo.inc/probo/pkg/agentrun"
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/iam"
|
||||
@@ -1175,7 +1176,7 @@ func (r *organizationResolver) Tasks(ctx context.Context, obj *types.Organizatio
|
||||
|
||||
// AgentRuns is the resolver for the agentRuns field.
|
||||
func (r *organizationResolver) AgentRuns(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.AgentRunOrderBy) (*types.AgentRunConnection, error) {
|
||||
scope, err := r.authorize(ctx, obj.ID, probo.ActionAgentRunList)
|
||||
scope, err := r.authorize(ctx, obj.ID, agentrun.ActionAgentRunList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user