Skip to content

Commit 54bc7b3

Browse files
authored
add the integration caller (#2642)
1 parent 63c325b commit 54bc7b3

25 files changed

Lines changed: 48 additions & 225 deletions

config/helm-values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ coreConfiguration:
285285
# -- DisplayName is the display name of the virtual support identity, used for record attribution
286286
displayname: "Openlane Support" # @schema type:string; default:Openlane Support
287287
# -- SubjectID is the stable subject id of the virtual support identity used for created_by/updated_by
288-
# attribution. It must be a valid ULID and is consistent without a backing user row. Default should match anon.SupportSubjectID
288+
# attribution. It must be a valid ULID and is consistent without a backing user row. Default should match auth.SupportSubjectID
289289
subjectid: "01JSPPRT000000000000000000" # @schema type:string; default:01JSPPRT000000000000000000
290290
# -- IssuerURL is the issuer URL of the second factor identity provider
291291
issuerurl: "" # @schema type:string

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ require (
108108
github.com/theopenlane/go-client v0.12.5
109109
github.com/theopenlane/gqlgen-plugins v0.14.7
110110
github.com/theopenlane/httpsling v0.3.0
111-
github.com/theopenlane/iam v0.35.1
111+
github.com/theopenlane/iam v0.35.4
112112
github.com/theopenlane/newman v0.4.2
113113
github.com/theopenlane/riverboat v0.9.18
114114
github.com/theopenlane/utils v0.7.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,8 +740,8 @@ github.com/theopenlane/gqlgen-plugins v0.14.7 h1:B9I6tpgevch3xQfV3qqRTpxHIlJvwtX
740740
github.com/theopenlane/gqlgen-plugins v0.14.7/go.mod h1:fUjo1cVKEAPLhtRrH+iJtrfivCNp+GxVSB/UJgVBDuA=
741741
github.com/theopenlane/httpsling v0.3.0 h1:Bad0dGdqCqAB8UVDyVo+YCevzRvGHhmkK22F7T3pXtY=
742742
github.com/theopenlane/httpsling v0.3.0/go.mod h1:iJc3XRLYTFIpfCnPpLZVMBP0xsWIPAb7ozARtQoclAE=
743-
github.com/theopenlane/iam v0.35.1 h1:F/tTPwmS7gO1TM0WOleco3z5K+h44QTZY/VUC9i/QdA=
744-
github.com/theopenlane/iam v0.35.1/go.mod h1:O60TH2GCj6zfXJ8VwKbP6aWZ7l4m7zCK2Qtbrn3bmFo=
743+
github.com/theopenlane/iam v0.35.4 h1:XnCfCCAXF7lCqtqzkxyeMUhkIe3hCBkL4X4UyJFk3SI=
744+
github.com/theopenlane/iam v0.35.4/go.mod h1:ZwJNFkCURwpyftECj/o4cu6qifMSdWtblFkzdnU8/Qk=
745745
github.com/theopenlane/newman v0.4.2 h1:8hcZkPBZgPrROB9UXZSQv4xDUP7KDya2o8WfYokXCl0=
746746
github.com/theopenlane/newman v0.4.2/go.mod h1:tCDhl2yzEFNg387YdQK5ztgwgH0dYgDnTB8SPqPNRbY=
747747
github.com/theopenlane/oscalot v0.1.0 h1:ExYiMU4Q1ezbGq77sxkgahmfmc46L+2NqB39fg0HXjU=

internal/ent/hooks/trustcenterndarequest.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"github.com/theopenlane/core/internal/ent/generated/user"
2525
"github.com/theopenlane/core/internal/httpserve/authmanager"
2626
emaildef "github.com/theopenlane/core/internal/integrations/definitions/email"
27-
"github.com/theopenlane/core/pkg/anon"
2827
"github.com/theopenlane/core/pkg/logx"
2928
)
3029

@@ -54,7 +53,7 @@ func HookTrustCenterNDARequestCreate() ent.Hook {
5453
email, _ := m.Email()
5554

5655
queryCtx := ctx
57-
if anon.IsTrustCenter(ctx) {
56+
if auth.IsTrustCenterFromContext(ctx) {
5857
queryCtx = privacy.DecisionContext(ctx, privacy.Allow)
5958
}
6059

internal/ent/interceptors/controls.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/theopenlane/core/internal/ent/generated/intercept"
1515
"github.com/theopenlane/core/internal/ent/privacy/rule"
1616
"github.com/theopenlane/core/internal/ent/privacy/utils"
17-
"github.com/theopenlane/core/pkg/anon"
1817
"github.com/theopenlane/core/pkg/logx"
1918
)
2019

@@ -33,7 +32,7 @@ func InterceptorTrustCenterControl() ent.Interceptor {
3332
// 1. marked as trust center controls (cloned from the trust center standard)
3433
// 2. have public visibility
3534
// 3. owned by the trust center's organization
36-
if anon.IsTrustCenter(ctx) {
35+
if auth.IsTrustCenterFromContext(ctx) {
3736
orgID, err := auth.GetOrganizationIDFromContext(ctx)
3837
if err != nil {
3938
logx.FromContext(ctx).Err(err).Msg("failed to get organization ID from context for trust center control query")

internal/ent/interceptors/subprocessor.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/theopenlane/core/internal/ent/generated/intercept"
1010
"github.com/theopenlane/core/internal/ent/generated/subprocessor"
1111
"github.com/theopenlane/core/internal/ent/generated/trustcentersubprocessor"
12-
"github.com/theopenlane/core/pkg/anon"
1312
"github.com/theopenlane/iam/auth"
1413
)
1514

@@ -18,7 +17,7 @@ func TraverseSubprocessor() ent.Interceptor {
1817
return intercept.TraverseSubprocessor(func(ctx context.Context, q *generated.SubprocessorQuery) error {
1918
// allow anonymous access to subprocessors this will only allow view
2019
// access to the trust center-owned subprocessors
21-
if tcID, _, ok := anon.TrustCenterScope(ctx); ok {
20+
if tcID, _, ok := auth.TrustCenterScopeFromContext(ctx); ok {
2221
q.Where(
2322
subprocessor.Or(
2423
subprocessor.And(

internal/ent/privacy/policy/checks.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
access "github.com/theopenlane/core/internal/ent/privacy"
2222
"github.com/theopenlane/core/internal/ent/privacy/rule"
2323
"github.com/theopenlane/core/internal/ent/privacy/utils"
24-
"github.com/theopenlane/core/pkg/anon"
2524
"github.com/theopenlane/core/pkg/logx"
2625
"github.com/theopenlane/core/pkg/mapx"
2726
)
@@ -136,7 +135,7 @@ func CanEditObjectUnderParents(parents []string, fetch func(ctx context.Context,
136135
// CheckOrgReadAccess checks if the requestor has access to read the organization
137136
func CheckOrgReadAccess() privacy.QueryRule {
138137
return privacy.QueryRuleFunc(func(ctx context.Context, q ent.Query) error {
139-
if anon.IsTrustCenter(ctx) {
138+
if auth.IsTrustCenterFromContext(ctx) {
140139
return privacy.Denyf("anonymous users cannot access organization data")
141140
}
142141

@@ -404,7 +403,7 @@ func mapEdgeToObjectType(ctx context.Context, schema string, edge string) authzg
404403
// for an anon trust center request and the only edge to check is for the
405404
// trust_center edge. This allows the setting of the edge on a trust center child when creating things like an nda request
406405
func allowTrustCenterEdgeForAnon(ctx context.Context, edges []string) bool {
407-
if !anon.IsTrustCenter(ctx) {
406+
if !auth.IsTrustCenterFromContext(ctx) {
408407
return false
409408
}
410409

internal/ent/privacy/rule/trustcenter.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/theopenlane/core/internal/ent/generated"
1111
"github.com/theopenlane/core/internal/ent/generated/privacy"
1212
"github.com/theopenlane/core/internal/ent/privacy/utils"
13-
"github.com/theopenlane/core/pkg/anon"
1413
"github.com/theopenlane/core/pkg/logx"
1514
"github.com/theopenlane/iam/auth"
1615
"github.com/theopenlane/iam/fgax"
@@ -37,7 +36,7 @@ func AllowIfTrustCenterAnonRequest() privacy.MutationRule {
3736
return privacy.MutationRuleFunc(func(ctx context.Context, _ ent.Mutation) error {
3837
logx.FromContext(ctx).Debug().Msg("checking for trust center anon context")
3938

40-
if anon.IsTrustCenter(ctx) {
39+
if auth.IsTrustCenterFromContext(ctx) {
4140
return privacy.Allow
4241
}
4342

internal/ent/schema/mixin_grouppermissions.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"github.com/theopenlane/core/internal/ent/hooks"
2727
access "github.com/theopenlane/core/internal/ent/privacy"
2828
"github.com/theopenlane/core/internal/ent/privacy/rule"
29-
"github.com/theopenlane/core/pkg/anon"
3029
"github.com/theopenlane/core/pkg/logx"
3130
"github.com/theopenlane/entx/accessmap"
3231
)
@@ -192,7 +191,7 @@ func (g GroupPermissionsMixin) Interceptors() []ent.Interceptor {
192191
// except for blocked groups (e.g. controls)
193192
return []ent.Interceptor{intercept.TraverseFunc(func(ctx context.Context, q intercept.Query) error {
194193
// anonymous trust center users don't belong to groups, skip group filtering
195-
if anon.IsTrustCenter(ctx) {
194+
if auth.IsTrustCenterFromContext(ctx) {
196195
return nil
197196
}
198197

internal/ent/schema/mixin_orgowned.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/theopenlane/core/internal/ent/hooks"
1919
"github.com/theopenlane/core/internal/ent/privacy/rule"
2020
"github.com/theopenlane/core/internal/ent/privacy/utils"
21-
"github.com/theopenlane/core/pkg/anon"
2221
"github.com/theopenlane/core/pkg/logx"
2322
)
2423

@@ -252,10 +251,10 @@ var defaultOrgInterceptorFunc InterceptorFunc = func(o ObjectOwnedMixin) ent.Int
252251
}
253252

254253
// classify the anonymous caller for the access checks below
255-
isAnon := anon.IsAnonymous(ctx)
254+
isAnon := auth.IsAnonymousFromContext(ctx)
256255

257256
// questionnaire callers only happen via REST handlers
258-
isQuestionnaireCaller := anon.IsQuestionnaire(ctx)
257+
isQuestionnaireCaller := auth.IsQuestionnaireFromContext(ctx)
259258

260259
// Trust Center anon users without GraphQL key are blocked by BlockNonTrustCenterAnonymous middleware;
261260
// questionnaire callers are legitimate REST callers and fall through to the org filter further down
@@ -312,7 +311,7 @@ func isAnonTrustCenterCaller(ctx context.Context) (string, bool, error) {
312311
return "", false, auth.ErrNoAuthUser
313312
}
314313

315-
if _, orgID, ok := anon.TrustCenterScope(ctx); ok {
314+
if _, orgID, ok := auth.TrustCenterScopeFromContext(ctx); ok {
316315
return orgID, true, nil
317316
}
318317

0 commit comments

Comments
 (0)