Repository navigation
feat(dir): add AGNTCY identity claims and badge verification - #2292
Conversation
|
The latest Buf updates on your PR. Results from workflow Buf CI / verify-proto (pull_request).
|
There was a problem hiding this comment.
@sriaradhyula LGTM overall, nice work!
For next steps, I think we need to decide to either:
- rebase and patch the PR based on the nits above and merge
- bring in #2329 into this PR and implement AGNTCY as the first provider
- with code managed within DIR repo as a go package
- with code managed somewhere else as either a go package or a gRPC server implementing the required interface
Let me know your thoughts, happy to help here!
muscariello
left a comment
There was a problem hiding this comment.
Thanks for this. I read the resolver, the reconciler wiring and the database changes, and ran the PR's unit tests at this head: client identity, reconciler identity, server database and controller all pass. I didn't run the live E2E, the race runs or lint.
The result binding looks solid. Version, kind, profile, policy, verifier ID, subject, CID and the request digest (which carries the nonce) are all checked, the result is verified against the pinned key, redirects are off, and the claim signature is checked again locally.
Two bugs (inline):
- Expiry in verified search depends on the host's timezone. A result that expired hours ago can still be returned as verified. The fix is three
.UTC()calls. - The defaults make every verification expire before the next run.
Structural:
3. The key-only Resolve path is used only by tests, and it skips the badge check.
4. This no longer fits main. #2304 (ANS) reworked the resolver set, and a trial merge conflicts in reconciler/tasks/identity/config.go, resolve.go, task.go, server/database/gorm/identity_claims.go and docs/content/dir/dir-component-identity.md. Details on task.go:372.
5. The verifier (agntcy/identity#182) and the Node fix (agntcy/identity#181) are both open drafts, last updated Oct 7, and the protocol is a draft v2. Nothing changes unless a verifier URL is set, so the risk is small. But this adds a DB column, config and docs for a service that has no release yet. It's worth deciding whether to merge ahead of it, and at least marking the docs experimental.
Small: CI Lint fails on two findings in reconciler/tasks/identity/task.go: wsl_v5 at line 118 and nlreturn at line 312.
On @ramizpolic's question, I'd rebase and patch rather than bring #2329 in. #2329 is a new gRPC API with no agreed design yet, and adding it would make an already large PR larger. This protocol is HTTP and JWS, so it can be wrapped once #2329 exists.
Signed-off-by: Sri Aradhyula <[email protected]>
1b8517f to
8c83ae2
Compare
Signed-off-by: Sri Aradhyula <[email protected]>
|
Rebased and patched without expanding scope into #2329. The docs explicitly mark the integration experimental and identify both unreleased Identity prerequisites and the database migration. Merge timing remains a maintainer decision. The lint findings are fixed. I tested protocol bindings and rejection cases with unit/TLS fixtures, then ran race tests across identity resolvers, reconciliation, database, controller and OCI storage. I also ran the live E2E with real services, covering valid claims, CID mismatches, wrong signers, expired badges, verifier outages and recovery. All passed, along with full-module lint and the documentation build. @ramizpolic @muscariello — I’ve replied to the inline comments with the fixes. Can I resolve the addressed review threads? |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
muscariello
left a comment
There was a problem hiding this comment.
Thanks, I checked each fix in the code at this head, not only the replies. All six of my threads are addressed, so feel free to resolve them:
- the three
.UTC()changes are in, and the database tests pass under UTC, Rome and New York; - startup refuses an interval at or above
max_verification_age, and that's tested; Resolvewithout a claim fails asFinal, and the badge requirement is enforced;- the resolver now sits in
main's scheme set, with claim-aware entries skipping the cache, and a failed reload returns an error fromRun; - the docs are marked experimental and name identity#181, identity#182 and the migration.
Client identity, reconciler identity, and the server database tests all pass locally.
One new bug came in with the rebase, inline on policy_invalidation.go:76. Once a claim passes its deadline and is then written as failed, the read gate keeps the verdict it reached while the claim was verified. I reproduced it, and the fix is one line.
Two smaller points, also inline: the docs' outage guarantee doesn't hold for the read gate, and the Resolve signature change breaks outside implementers of a public interface.
| return before.GetStatus() != after.GetStatus() || | ||
| before.Subject != after.Subject |
There was a problem hiding this comment.
Since this compares GetStatus(), a verified row that is past its deadline already reads as failed. When the reconciler then writes the claim as failed, this sees failed against failed and returns false. The verdict isn't superseded, so the read gate keeps the answer it reached while the claim was verified.
That's the verifier-outage path: the previous result is kept through grace until the deadline, and then the failed result is written.
To reproduce, in package gorm next to the existing invalidation tests:
until := time.Now().Add(time.Second)
verified := identityClaim(types.ClaimStatusVerified, "agntcy://Agent")
verified.ValidUntil = &until
require.NoError(t, db.UpsertIdentityClaim(verified))
seedVerdict(t, db)
time.Sleep(1500 * time.Millisecond)
require.NoError(t, db.UpsertIdentityClaim(identityClaim(types.ClaimStatusFailed, "agntcy://Agent")))
assertSuperseded(t, db) // fails: the verdict is still "evaluated"Comparing both values fixes it, and keeps the case where an expired row is re-verified:
| return before.GetStatus() != after.GetStatus() || | |
| before.Subject != after.Subject | |
| return before.Status != after.Status || | |
| before.GetStatus() != after.GetStatus() || | |
| before.Subject != after.Subject |
With that change the reproduction passes, and the existing invalidation and identity tests still pass.
There was a problem hiding this comment.
Agreed — comparing only the effective status misses the stored verified → failed transition after expiry. I’ll compare both stored and effective status as suggested, add the expired-then-failed regression test, retain the renewal-after-expiry test, and check that the old policy verdict is superseded.
|
|
||
| An outage may preserve the previous observation only until its deadline and the | ||
| AGNTCY scheme grace (the configured maximum verification age). Expired results are reported as failed by | ||
| status reads and excluded by verified search immediately, even between runs. |
There was a problem hiding this comment.
This holds for status and verified search, but not for the policy read gate. A verdict is only superseded when something writes, and policy_invalidation.go already says a clock-dependent fact "cannot be kept correct by invalidation". After a deadline passes, the gate can keep the previous verdict for up to one reconciliation interval, until the next write. That assumes the fix on policy_invalidation.go:76.
Please either say so here, or supersede the verdicts when a result's deadline passes.
There was a problem hiding this comment.
I’ll clarify that status and verified search honor expiry immediately, while stored policy verdicts are invalidated by the next successful reconciliation write. I won’t promise a strict one-interval bound when reconciliation is interrupted or cannot write. Immediate deadline enforcement in the policy gate would need a separate design change.
| // claim's DER-encoded X.509 certificate, empty when the claim has none; | ||
| // only SPIFFE and ANS resolution read it. | ||
| Resolve(ctx context.Context, subject string, certificate []byte) ([]crypto.PublicKey, error) | ||
| Resolve(ctx context.Context, subject string, certificate []byte, opts ...Option) ([]crypto.PublicKey, error) |
There was a problem hiding this comment.
Adding opts here changes a public interface in the client module. Callers are unaffected, but any implementation of resolvers.Resolver outside this repo stops compiling. It's worth a line in the changelog.
There was a problem hiding this comment.
Agreed. I’ll add a breaking-change note under Unreleased, explaining that external Resolver implementations must add opts ...resolvers.Option to Resolve; implementations that do not use the options can ignore them. Existing call sites remain compatible.
muscariello
left a comment
There was a problem hiding this comment.
Requesting changes to hold the merge on the verdict-invalidation bug in server/database/gorm/policy_invalidation.go:76, see the inline comment in my previous review. After a claim's deadline passes and it is written as failed, the stored verdict is not superseded, so the read gate keeps serving what it decided while the claim verified. That fails open in the gate. The suggestion there is the fix, and the reproduction test there should go in with it.
The other two points from that review, the docs line and the changelog note, don't block. I'll approve once the fix and its test are in.
Compare stored and effective claim status, and cover expired verified evidence being replaced with failure. Clarify policy freshness limits and document the resolver interface change. Signed-off-by: Sri Aradhyula <[email protected]>
Replace the Python harness with an opt-in Ginkgo suite using disposable real services. Preserve enrollment, native OCI binding, verification rejection and outage recovery coverage, with cleanup and JSON reporting. Signed-off-by: Sri Aradhyula <[email protected]>
|
This PR exceeds the recommended size of 2000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note that this PR might take longer to review due to large size. |
|
@muscariello @ramizpolic could you take another look when you have a chance? I’ve pushed the follow-up fixes: stored/effective status comparison with the expired-to-failed policy-gate regression test, clarified the policy expiry guarantees, and added the Resolver interface breaking-change note. I also ported the live harness to Go/Ginkgo; all 7 live scenarios passed. The PR description has the test details and notes the unrelated pre-existing policy test-helper race. Thanks! |
muscariello
left a comment
There was a problem hiding this comment.
Approving. I checked the follow-up commits in the code:
identityClaimFactsChangedcompares both the stored and the effective status.TestPolicyGate_ExpiredClaimWrittenAsFailedSupersedesfails with the fix reverted and passes with it, and it checks that the gate no longer admits the record.- The docs now state the policy-verdict limit accurately, and the changelog has the breaking
Resolveentry. - The Ginkgo suite replaces the Python harness with no new dependencies. It skips unless
AGNTCY_E2E=1is set, and CI doesn't run it.
Thanks for working through all of this. I've confirmed the mapSource.Pull race you reported on main, and it's being fixed separately.
Summary
Adds opt-in
agntcy://identity verification through an external AGNTCY Identity Verifier. Directory authenticates the signed HTTP/JWS result, enforces the configured badge policy and exact claim/request bindings, then verifies the native claim signature locally. Native claims remain OCI referrers; badges remain in Identity Node.Rebased onto
mainat9fd9150eaeaa900e1f176d06076989ba89f9cb2b, including the ANS resolver registry and transactional policy invalidation. Closes #2291. The separate gRPC provider design in #2329 remains outside this PR.Review fixes
WithClaim,WithValidUntil). Register AGNTCY in the scheme map, with bounded grace and no subject-only evidence cache./v1/resolvepath, parallelResolveClaiminterface and deadline cache. Complete claims are required even in control-only mode; badge checks remain required by default.Resolver.Resolveinterface.Local validation
Passed with Directory's Go 1.27.2 toolchain:
Repository-configured golangci-lint 2.14.0 reports zero issues for the full client, reconciler and server modules and the new Go/Ginkgo suite, without changed-line filtering. MkDocs build, changed-page Markdown/spelling checks and
git diff --checkpass.I tested protocol and integration behavior with the live Go/Ginkgo
tests/e2e/agntcysuite: 7/7 specs passed against real Keycloak, PostgreSQL, Identity Node, verifier, Directory daemon and OCI registry. This covers enrollment, native claim storage and exact manifest binding, verified search, same-agent/different-CID badge rejection, unrelated signer rejection, expired badges, outage expiry and recovery. Cleanup removed all fixture containers and the network. Reproduction instructions describe the required binaries, opt-in environment variables and Ginkgo JSON report.The new policy regression failed before the fix and passes afterward. Database/controller race suites and the normal
go -C server test ./policy/...suite pass. Expanding race coverage to./policy/...exposes a pre-existing race in the unchanged test helpermapSource.Pull(server/policy/evaluation_test.go:28), where parallelTestRegistryPolicies_DecidesOnIndexedAtsubtests append to a shared slice. The isolated test reproduces it; that broader race run is not passing.Experimental dependencies
The
agntcy.identity-verification.v2protocol and service remain unreleased drafts. The integration stays off unless a verifier URL is configured. The nullablevalid_untildatabase column is added even when the verifier is disabled; existing unbounded rows retain their behavior. Documentation explicitly identifies these boundaries and scheduling requirements.Companion verifier: identity#182, commit
53ec1e34049ddb34e8caed9762b4ab0ae5516838. Node controller fix: identity#181, commit037e25d3a96e47033872d7ebeb75a9944721b337.The badge policy proves agent control and exact record consistency using Node's subject-key-backed badge verification. Independent issuer accreditation and external credential status-list revocation require additional policies/adapters.