Update RBAC on console
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -316,16 +316,23 @@ func GetTenantService(ctx context.Context, proboSvc *probo.Service, tenantID gid
|
||||
return proboSvc.WithTenant(tenantID)
|
||||
}
|
||||
|
||||
func (r *Resolver) MustBeAuthorized(ctx context.Context, entityID gid.GID, action iam.Action) {
|
||||
func (r *Resolver) MustAuthorize(ctx context.Context, entityID gid.GID, action iam.Action) {
|
||||
user := connect_v1.IdentityFromContext(ctx)
|
||||
apiKey := connect_v1.APIKeyFromContext(ctx)
|
||||
// apiKey := connect_v1.APIKeyFromContext(ctx)
|
||||
|
||||
var credentialID *gid.GID
|
||||
if apiKey != nil {
|
||||
credentialID = &apiKey.ID
|
||||
}
|
||||
// var credentialID *gid.GID
|
||||
// if apiKey != nil {
|
||||
// credentialID = &apiKey.ID
|
||||
// }
|
||||
|
||||
err := r.iam.LegacyAccessManagementService.Authorize(ctx, user.ID, credentialID, entityID, action)
|
||||
err := r.iam.Authorizer.Authorize(
|
||||
ctx,
|
||||
iam.AuthorizeParams{
|
||||
Principal: user.ID,
|
||||
Resource: entityID,
|
||||
Action: action,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -252,6 +252,7 @@ type ComplexityRoot struct {
|
||||
Measures func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.MeasureOrderBy, filter *types.MeasureFilter) int
|
||||
Name func(childComplexity int) int
|
||||
Obligations func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ObligationOrderBy, filter *types.ObligationFilter) int
|
||||
Organization func(childComplexity int) int
|
||||
SectionTitle func(childComplexity int) int
|
||||
Snapshots func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.SnapshotOrderBy) int
|
||||
StateOfApplicabilityControls func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.StateOfApplicabilityOrderBy) int
|
||||
@@ -1932,6 +1933,8 @@ type ContinualImprovementConnectionResolver interface {
|
||||
TotalCount(ctx context.Context, obj *types.ContinualImprovementConnection) (int, error)
|
||||
}
|
||||
type ControlResolver interface {
|
||||
Organization(ctx context.Context, obj *types.Control) (*types.Organization, error)
|
||||
|
||||
Framework(ctx context.Context, obj *types.Control) (*types.Framework, error)
|
||||
Measures(ctx context.Context, obj *types.Control, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.MeasureOrderBy, filter *types.MeasureFilter) (*types.MeasureConnection, error)
|
||||
Documents(ctx context.Context, obj *types.Control, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.DocumentOrderBy, filter *types.DocumentFilter) (*types.DocumentConnection, error)
|
||||
@@ -2926,6 +2929,12 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
||||
}
|
||||
|
||||
return e.complexity.Control.Obligations(childComplexity, args["first"].(*int), args["after"].(*page.CursorKey), args["last"].(*int), args["before"].(*page.CursorKey), args["orderBy"].(*types.ObligationOrderBy), args["filter"].(*types.ObligationFilter)), true
|
||||
case "Control.organization":
|
||||
if e.complexity.Control.Organization == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.Control.Organization(childComplexity), true
|
||||
case "Control.sectionTitle":
|
||||
if e.complexity.Control.SectionTitle == nil {
|
||||
break
|
||||
@@ -11762,6 +11771,7 @@ type Framework implements Node {
|
||||
|
||||
type Control implements Node {
|
||||
id: ID!
|
||||
organization: Organization @goField(forceResolver: true)
|
||||
sectionTitle: String!
|
||||
name: String!
|
||||
description: String
|
||||
@@ -21218,6 +21228,109 @@ func (ec *executionContext) fieldContext_Control_id(_ context.Context, field gra
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Control_organization(ctx context.Context, field graphql.CollectedField, obj *types.Control) (ret graphql.Marshaler) {
|
||||
return graphql.ResolveField(
|
||||
ctx,
|
||||
ec.OperationContext,
|
||||
field,
|
||||
ec.fieldContext_Control_organization,
|
||||
func(ctx context.Context) (any, error) {
|
||||
return ec.resolvers.Control().Organization(ctx, obj)
|
||||
},
|
||||
nil,
|
||||
ec.marshalOOrganization2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐOrganization,
|
||||
true,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_Control_organization(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "Control",
|
||||
Field: field,
|
||||
IsMethod: true,
|
||||
IsResolver: true,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
switch field.Name {
|
||||
case "id":
|
||||
return ec.fieldContext_Organization_id(ctx, field)
|
||||
case "name":
|
||||
return ec.fieldContext_Organization_name(ctx, field)
|
||||
case "logoUrl":
|
||||
return ec.fieldContext_Organization_logoUrl(ctx, field)
|
||||
case "horizontalLogoUrl":
|
||||
return ec.fieldContext_Organization_horizontalLogoUrl(ctx, field)
|
||||
case "description":
|
||||
return ec.fieldContext_Organization_description(ctx, field)
|
||||
case "websiteUrl":
|
||||
return ec.fieldContext_Organization_websiteUrl(ctx, field)
|
||||
case "email":
|
||||
return ec.fieldContext_Organization_email(ctx, field)
|
||||
case "headquarterAddress":
|
||||
return ec.fieldContext_Organization_headquarterAddress(ctx, field)
|
||||
case "context":
|
||||
return ec.fieldContext_Organization_context(ctx, field)
|
||||
case "slackConnections":
|
||||
return ec.fieldContext_Organization_slackConnections(ctx, field)
|
||||
case "frameworks":
|
||||
return ec.fieldContext_Organization_frameworks(ctx, field)
|
||||
case "controls":
|
||||
return ec.fieldContext_Organization_controls(ctx, field)
|
||||
case "vendors":
|
||||
return ec.fieldContext_Organization_vendors(ctx, field)
|
||||
case "peoples":
|
||||
return ec.fieldContext_Organization_peoples(ctx, field)
|
||||
case "documents":
|
||||
return ec.fieldContext_Organization_documents(ctx, field)
|
||||
case "meetings":
|
||||
return ec.fieldContext_Organization_meetings(ctx, field)
|
||||
case "statesOfApplicability":
|
||||
return ec.fieldContext_Organization_statesOfApplicability(ctx, field)
|
||||
case "measures":
|
||||
return ec.fieldContext_Organization_measures(ctx, field)
|
||||
case "risks":
|
||||
return ec.fieldContext_Organization_risks(ctx, field)
|
||||
case "tasks":
|
||||
return ec.fieldContext_Organization_tasks(ctx, field)
|
||||
case "assets":
|
||||
return ec.fieldContext_Organization_assets(ctx, field)
|
||||
case "data":
|
||||
return ec.fieldContext_Organization_data(ctx, field)
|
||||
case "audits":
|
||||
return ec.fieldContext_Organization_audits(ctx, field)
|
||||
case "nonconformities":
|
||||
return ec.fieldContext_Organization_nonconformities(ctx, field)
|
||||
case "obligations":
|
||||
return ec.fieldContext_Organization_obligations(ctx, field)
|
||||
case "continualImprovements":
|
||||
return ec.fieldContext_Organization_continualImprovements(ctx, field)
|
||||
case "rightsRequests":
|
||||
return ec.fieldContext_Organization_rightsRequests(ctx, field)
|
||||
case "processingActivities":
|
||||
return ec.fieldContext_Organization_processingActivities(ctx, field)
|
||||
case "dataProtectionImpactAssessments":
|
||||
return ec.fieldContext_Organization_dataProtectionImpactAssessments(ctx, field)
|
||||
case "transferImpactAssessments":
|
||||
return ec.fieldContext_Organization_transferImpactAssessments(ctx, field)
|
||||
case "snapshots":
|
||||
return ec.fieldContext_Organization_snapshots(ctx, field)
|
||||
case "trustCenterFiles":
|
||||
return ec.fieldContext_Organization_trustCenterFiles(ctx, field)
|
||||
case "trustCenter":
|
||||
return ec.fieldContext_Organization_trustCenter(ctx, field)
|
||||
case "customDomain":
|
||||
return ec.fieldContext_Organization_customDomain(ctx, field)
|
||||
case "createdAt":
|
||||
return ec.fieldContext_Organization_createdAt(ctx, field)
|
||||
case "updatedAt":
|
||||
return ec.fieldContext_Organization_updatedAt(ctx, field)
|
||||
}
|
||||
return nil, fmt.Errorf("no field named %q was found under type Organization", field.Name)
|
||||
},
|
||||
}
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Control_sectionTitle(ctx context.Context, field graphql.CollectedField, obj *types.Control) (ret graphql.Marshaler) {
|
||||
return graphql.ResolveField(
|
||||
ctx,
|
||||
@@ -21951,6 +22064,8 @@ func (ec *executionContext) fieldContext_ControlEdge_node(_ context.Context, fie
|
||||
switch field.Name {
|
||||
case "id":
|
||||
return ec.fieldContext_Control_id(ctx, field)
|
||||
case "organization":
|
||||
return ec.fieldContext_Control_organization(ctx, field)
|
||||
case "sectionTitle":
|
||||
return ec.fieldContext_Control_sectionTitle(ctx, field)
|
||||
case "name":
|
||||
@@ -51012,6 +51127,8 @@ func (ec *executionContext) fieldContext_UpdateControlPayload_control(_ context.
|
||||
switch field.Name {
|
||||
case "id":
|
||||
return ec.fieldContext_Control_id(ctx, field)
|
||||
case "organization":
|
||||
return ec.fieldContext_Control_organization(ctx, field)
|
||||
case "sectionTitle":
|
||||
return ec.fieldContext_Control_sectionTitle(ctx, field)
|
||||
case "name":
|
||||
@@ -67994,6 +68111,39 @@ func (ec *executionContext) _Control(ctx context.Context, sel ast.SelectionSet,
|
||||
if out.Values[i] == graphql.Null {
|
||||
atomic.AddUint32(&out.Invalids, 1)
|
||||
}
|
||||
case "organization":
|
||||
field := field
|
||||
|
||||
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
}
|
||||
}()
|
||||
res = ec._Control_organization(ctx, field, obj)
|
||||
return res
|
||||
}
|
||||
|
||||
if field.Deferrable != nil {
|
||||
dfs, ok := deferred[field.Deferrable.Label]
|
||||
di := 0
|
||||
if ok {
|
||||
dfs.AddField(field)
|
||||
di = len(dfs.Values) - 1
|
||||
} else {
|
||||
dfs = graphql.NewFieldSet([]graphql.CollectedField{field})
|
||||
deferred[field.Deferrable.Label] = dfs
|
||||
}
|
||||
dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler {
|
||||
return innerFunc(ctx, dfs)
|
||||
})
|
||||
|
||||
// don't run the out.Concurrently() call below
|
||||
out.Values[i] = graphql.Null
|
||||
continue
|
||||
}
|
||||
|
||||
out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
|
||||
case "sectionTitle":
|
||||
out.Values[i] = ec._Control_sectionTitle(ctx, field, obj)
|
||||
if out.Values[i] == graphql.Null {
|
||||
|
||||
@@ -51,6 +51,9 @@ func NewControlEdge(control *coredata.Control, orderField coredata.ControlOrderF
|
||||
func NewControl(control *coredata.Control) *Control {
|
||||
return &Control{
|
||||
ID: control.ID,
|
||||
Organization: &Organization{
|
||||
ID: control.OrganizationID,
|
||||
},
|
||||
Framework: &Framework{
|
||||
ID: control.FrameworkID,
|
||||
},
|
||||
|
||||
@@ -168,6 +168,7 @@ type ContinualImprovementFilter struct {
|
||||
|
||||
type Control struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Organization *Organization `json:"organization,omitempty"`
|
||||
SectionTitle string `json:"sectionTitle"`
|
||||
Name string `json:"name"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user