Agent Mesh
Go a2aa2a-protocolagent-meshagentic-aiinferencemcpmeshmesh-networknetwork-securitynetworking-aip2p-network
identity: keep the authorizer error when a publish grant is refused
HosniBelfeki25e05fd3fe48
diff --git a/internal/identity/biscuit.go b/internal/identity/biscuit.goindex 62cf426a..c9d53758 100644--- a/internal/identity/biscuit.go+++ b/internal/identity/biscuit.go@@ -836,7 +836,7 @@ func RequirePublish(b *biscuit.Biscuit, key ed25519.PublicKey, svcType, svcNameauthorizer.AddPolicy(p)}if err := authorizer.Authorize(); err != nil {- return fmt.Errorf("credential does not grant serving %s://%s", svcType, svcName)+ return fmt.Errorf("credential does not grant serving %s://%s: %w", svcType, svcName, err)}return nil}diff --git a/internal/identity/biscuit_test.go b/internal/identity/biscuit_test.goindex 9d0e0d38..18354b1d 100644--- a/internal/identity/biscuit_test.go+++ b/internal/identity/biscuit_test.go@@ -804,6 +804,15 @@ func TestMintBiscuitToken_PublishFacts(t *testing.T) {}}+ // A refusal keeps the authorizer's reason: no policy matched is not the+ // same as a Datalog world that ran out of time on a granted service.+ if err := RequirePublish(b, pub, "mcp", "clock", nil, testTimeout); !errors.Is(err, biscuit.ErrNoMatchingPolicy) {+ t.Errorf("RequirePublish(mcp://clock) = %v, want an error wrapping %v", err, biscuit.ErrNoMatchingPolicy)+ }+ if err := RequirePublish(b, pub, "mcp", "calc", nil, time.Nanosecond); !errors.Is(err, datalog.ErrWorldRunLimitTimeout) {+ t.Errorf("RequirePublish(mcp://calc) with a 1ns timeout = %v, want an error wrapping %v", err, datalog.ErrWorldRunLimitTimeout)+ }+none, err := MintBootstrapBiscuitToken(priv, p, "publisher", time.Now().Add(time.Hour), nil, nil)if err != nil {t.Fatal(err)