Enforce IAM authorization on every console resolver
Audited pkg/server/api/console/v1 for resolvers that touched tenant data without calling r.authorize, batchAuthorize, or Permission. Closed every gap so every data-bearing field goes through IAM (and produces an audit log entry when an organization_id is present). * High-severity reads now authorize: accessSourceResolver.Connector and ConnectionStatus, controlResolver.Regulatory/Contractual/RiskAssessment, electronicSignatureResolver.CertificateFileURL/Events, commonThirdPartyResolver.LogoURL, and the proper accessSourceResolver/accessReviewCampaignResolver/auditLogEntryResolver Organization resolvers (authorize + dataloader load, fixing the latent empty-name bug from the previous force-resolver no-op implementations). * TotalCount/DetectedCount aggregates now authorize the matching list action across access review, audit log, statement of applicability, detected tracker, tracker pattern, and tracker resource connections. * queryResolver.CommonThirdParties authorizes against the principal's identity via the new identity-scoped CommonThirdPartyCatalogPolicy. * Add ActionCommonThirdPartyGet/List, ActionElectronicSignatureGet probo action constants; wire ActionElectronicSignatureGet into ViewerPolicy and AuditorPolicy. * Implement AuthorizationAttributes on CommonThirdParty (no org) and ElectronicSignature (organization_id) so the authorizer can resolve attributes for the new actions. * Delete the dead "type AccessReview" GraphQL type (no Go constructor, no frontend reference) and drop its orphan resolver bundle. Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
@@ -7,9 +7,14 @@ package console_v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/vikstrous/dataloadgen"
|
||||
"go.gearno.de/kit/log"
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/iam"
|
||||
"go.probo.inc/probo/pkg/probo"
|
||||
"go.probo.inc/probo/pkg/server/api/console/v1/dataloader"
|
||||
"go.probo.inc/probo/pkg/server/api/console/v1/schema"
|
||||
"go.probo.inc/probo/pkg/server/api/console/v1/types"
|
||||
"go.probo.inc/probo/pkg/server/gqlutils"
|
||||
@@ -17,7 +22,24 @@ import (
|
||||
|
||||
// Organization is the resolver for the organization field.
|
||||
func (r *auditLogEntryResolver) Organization(ctx context.Context, obj *types.AuditLogEntry) (*types.Organization, error) {
|
||||
return obj.Organization, nil
|
||||
if _, err := r.authorize(ctx, obj.ID, probo.ActionOrganizationGet); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
loaders := dataloader.FromContext(ctx)
|
||||
|
||||
organization, err := loaders.Organization.Load(ctx, obj.Organization.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) || errors.Is(err, dataloadgen.ErrNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return types.NewOrganization(organization), nil
|
||||
}
|
||||
|
||||
// Permission is the resolver for the permission field.
|
||||
@@ -27,6 +49,10 @@ func (r *auditLogEntryResolver) Permission(ctx context.Context, obj *types.Audit
|
||||
|
||||
// TotalCount is the resolver for the totalCount field.
|
||||
func (r *auditLogEntryConnectionResolver) TotalCount(ctx context.Context, obj *types.AuditLogEntryConnection) (int, error) {
|
||||
if _, err := r.authorize(ctx, obj.ParentID, iam.ActionAuditLogEntryList); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
filter := coredata.NewAuditLogEntryFilter()
|
||||
if obj.Filter != nil {
|
||||
filter = obj.Filter
|
||||
|
||||
Reference in New Issue
Block a user