Skip to content

Commit 8391ba4

Browse files
ashraffoudaclaude
andcommitted
feat(provision): allow council/ops read of another owner's deployment (get)
Fast-path the owner's own deployment.get (unchanged, no chain lookup); on a miss, resolve the owner from the on-chain contract and authorize the caller as owner-or-council, so an ops caller can inspect a deployment it does not own while driving a keyless migration. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 4511de9 commit 8391ba4

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

‎pkg/zos_api/deployment.go‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,22 @@ func (g *ZosAPI) deploymentGetHandler(ctx context.Context, payload []byte) (inte
6363
return nil, err
6464
}
6565

66-
return g.provisionStub.Get(ctx, peer.GetTwinID(ctx), args.ContractID)
67-
66+
// Fast path (unchanged behavior): the caller reads its own deployment — no chain lookup.
67+
twin := peer.GetTwinID(ctx)
68+
if dl, err := g.provisionStub.Get(ctx, twin, args.ContractID); err == nil {
69+
return dl, nil
70+
}
71+
// Slow path: not the caller's own deployment. Allow an ops/council read of another owner's
72+
// deployment (needed to drive a keyless migration) — resolve the owner from the on-chain
73+
// contract and authorize the caller as the owner or a council member.
74+
owner, oerr := g.ownerOfContract(ctx, args.ContractID)
75+
if oerr != nil {
76+
return nil, oerr
77+
}
78+
if aerr := g.authorizeMigration(ctx, owner); aerr != nil {
79+
return nil, aerr
80+
}
81+
return g.provisionStub.Get(ctx, owner, args.ContractID)
6882
}
6983

7084
func (g *ZosAPI) deploymentListHandler(ctx context.Context, payload []byte) (interface{}, error) {

0 commit comments

Comments
 (0)