Skip to content

Commit 150e5d3

Browse files
shouldnt' need privacy allow either
Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>
1 parent 34dcbe6 commit 150e5d3

2 files changed

Lines changed: 4 additions & 9 deletions

File tree

internal/ent/hooks/listeners_organization_cleanup.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/theopenlane/core/internal/ent/eventqueue"
1111
entgen "github.com/theopenlane/core/internal/ent/generated"
1212
"github.com/theopenlane/core/internal/ent/generated/organization"
13-
"github.com/theopenlane/core/internal/ent/generated/privacy"
1413
"github.com/theopenlane/core/internal/ent/hooks/contextx"
1514
"github.com/theopenlane/core/pkg/gala"
1615
"github.com/theopenlane/core/pkg/logx"
@@ -82,8 +81,7 @@ func handleOrganizationCascadeDelete(ctx gala.HandlerContext, payload eventqueue
8281
// organizationCleanupContext builds the context the cascade runs under, it bypasses privacy rules,
8382
// turns the cascaded deletes into hard deletes and opts the cascade into purging history rows
8483
func organizationCleanupContext(ctx context.Context, orgID string) context.Context {
85-
allowCtx := privacy.DecisionContext(ctx, privacy.Allow)
86-
allowCtx = auth.WithCaller(allowCtx, newOrganizationCleanupCaller(orgID))
84+
allowCtx := auth.WithCaller(ctx, newOrganizationCleanupCaller(orgID))
8785

8886
allowCtx = entx.SkipSoftDelete(allowCtx)
8987

@@ -94,8 +92,7 @@ func organizationCleanupContext(ctx context.Context, orgID string) context.Conte
9492
}
9593

9694
// newOrganizationCleanupCaller returns the caller the cascade runs as. It needs to reach every
97-
// record the organization owns regardless of who is deleting it, so it bypasses the organization
98-
// filter and FGA checks and identifies itself as an internal operation
95+
// record the organization owns regardless of who is deleting it, so it bypasses FGA checks and identifies itself as an internal operation
9996
func newOrganizationCleanupCaller(orgID string) *auth.Caller {
10097
return &auth.Caller{
10198
OrganizationID: orgID,

internal/ent/hooks/organization.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import (
2121
"github.com/theopenlane/core/internal/ent/generated/hook"
2222
"github.com/theopenlane/core/internal/ent/generated/organization"
2323
"github.com/theopenlane/core/internal/ent/generated/orgsubscription"
24-
"github.com/theopenlane/core/internal/ent/generated/privacy"
2524
"github.com/theopenlane/core/internal/ent/generated/sladefinition"
2625
"github.com/theopenlane/core/internal/ent/generated/usersetting"
26+
"github.com/theopenlane/core/internal/ent/privacy/rule"
2727
"github.com/theopenlane/core/internal/ent/privacy/utils"
2828
"github.com/theopenlane/core/internal/entitlements/reconciler"
2929
"github.com/theopenlane/core/internal/httpserve/authmanager"
@@ -143,9 +143,7 @@ func HookOrganization() ent.Hook {
143143
func HookOrganizationDelete() ent.Hook {
144144
return hook.On(func(next ent.Mutator) ent.Mutator {
145145
return hook.OrganizationFunc(func(ctx context.Context, m *generated.OrganizationMutation) (generated.Value, error) {
146-
// by pass checks on invite or pre-allowed request
147-
// this includes things like the edge-cleanup on user deletion
148-
if _, allow := privacy.DecisionFromContext(ctx); allow {
146+
if rule.IsInternalRequest(ctx) {
149147
return next.Mutate(ctx, m)
150148
}
151149

0 commit comments

Comments
 (0)