Skip to the content.

Task 39 - Identichnost i delegatsiya

Phase: 3 Status: done Owner: - Slug: identity-delegation

Goal

mTLS, API-klyuchi ili OAuth-sovmestimye bearer-tokeny dlya peer-vyzovov. Delegated request neset minimum identity claims i tool authority.

Acceptance criteria

Sub-tasks

Implementation notes

2026-08-13

src/agent/Mesh/Auth/ — novaya papka dlya inter-agent auth:

Config/AppConfig.cs — MeshConfig.PeerAuth { get; set; } = new().

Mesh/MeshServiceExtensions.cs — wire TokenIssuer, IIdentityProvider[] (Bearer/ApiKey/MTls), IPeerCredentialProvider.

TransportFactory.cs — pass IPeerCredentialProvider to HttpTransportAdapter (constructor injection).

HttpTransportAdapter.cs — use _credentials.ResolveAsync(targetAgentId, envelope.Auth) to apply outbound auth (replaces hardcoded “mesh-key” placeholder). Backward-compat fallback for peer.Auth.Type==”apikey” when no provider.

Program.cs — app.UseMiddleware<PeerAuthMiddleware>() after RateLimitMiddleware.

tests/Phase3Tests/PeerAuthTests.cs — 28 unit tests covering: token issue/verify, tampered rejection, expired rejection, depth limits, scope reduction subset check, Bearer/ApiKey/MTls providers (auth/reject/missing), credential provider (bearer/apikey/none modes, auth context, excessive depth), PeerCredentials.Apply, IdentityResult.HasScope, DelegationToken.GetScopes/HasScope.

Validation:

Scope / Likely files

src/agent/Mesh/Auth/

Dependencies

Risks / Rollback

Token leakage; korotkozhivushchie tokeny (5 min TTL) + scope reduction. mTLS — stub implementation, real verification — future work.