Add per-request Authorize dataloader to console v1

Resolving a typical Console GraphQL query triggers many parallel
authorize calls (one per resource per field resolver). This commit
collapses them via a dataloader: parallel calls within the same
request are gathered into a single iam.Authorizer.AuthorizeMulti pass,
and only fall back to per-item Authorize when AuthorizeMulti rejects
the whole batch (e.g. mixed organizations).

The loader key encodes resource id, action, options, and a canonical
JSON-encoded attribute map so logically identical calls share a key
while differing ones do not. The loader is created without caching so
repeated calls within a request still produce one audit log entry per
call. dataloader.NewAuthorizeFunc preserves the existing
authz.AuthorizeFunc signature and error mapping.

Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
Bryan Frimin
2026-05-23 11:28:51 -07:00
parent a862faee39
commit 5e9ff656d3
4 changed files with 267 additions and 1 deletions

View File

@@ -48,6 +48,7 @@ import (
type (
Resolver struct {
authorize authz.AuthorizeFunc
batchAuthorize authz.BatchAuthorizeFunc
probo *probo.Service
iam *iam.Service
esign *esign.Service