Skip to content

feat(identity): record identity/ownership verifiable claims - #2125

Closed
ramizpolic wants to merge 3 commits into
mainfrom
feat/identity-add
Closed

ramizpolic wants to merge 3 commits into
mainfrom
feat/identity-add

Conversation

@ramizpolic

Copy link
Copy Markdown
Member

Summary

Adds a verifiable identity/ownership claim system for OASF records (identity.v1), purely additive — naming.v1 is left fully intact and untouched in this PR (removed in a follow-up stacked PR).

  • proto/api: IdentityClaim/OwnershipClaim messages, IdentityService (GetIdentityStatus, Resolve), and the api/identity/v1 Go package: claim construction, detached-JWS signing/verification (ES256/ES384/EdDSA/RS256), mandatory per-trust-domain SPIFFE trust bundles (no silent fallback), and OCI referrer marshaling. Adds Record.GetIdentity/GetOwner/GetIdentityType/GetOwnerType annotation accessors and Record.GetDigest (sha256:hex form, for OCI/ai-catalog.io interop).
  • server: server/identity resolvers (dns/did/wellknown/spiffe) behind a common Resolver registry, the SSRF-safe utils/safefetch HTTP client they share, a unified claims DB table (record_cid + role), and eager claim verification wired into ingest.
  • client/cli/reconciler: SDK methods (SignAndAttachIdentityClaim/OwnershipClaim, GetIdentityStatus(ByName), Resolve), dirctl identity claim/status/resolve, identity/owner search flags, and a reconciler task that periodically re-verifies claims (catching key rotation, expiry, and revoked SPIFFE trust bundles).

Design note

This PR is deliberately additive-only so it builds and passes tests standing alone: naming.v1's NamingServiceClient, its DB API (NameVerificationDatabaseAPI), CLI, and reconciler task are untouched. A couple of naming collisions between the old and new code were resolved by keeping both (e.g. an expandNameWithProtocols helper duplicated under a different name) rather than removing anything — naming.v1's actual removal happens in the follow-up stacked PR (feat/identity-remove-legacy).

Verification

go build && go vet && go test pass across api, server, client, cli, reconciler, tests, samples/ard-over-ads.

…ntity.v1)

Introduces IdentityClaim/OwnershipClaim proto messages and IdentityService
(GetIdentityStatus, Resolve), plus the api/identity/v1 Go package: claim
construction, detached-JWS signing/verification (ES256/ES384/EdDSA/RS256,
mandatory SPIFFE trust bundles), and OCI referrer marshaling.

Adds Record.GetIdentity/GetOwner/GetIdentityType/GetOwnerType annotation
accessors and Record.GetDigest (sha256:hex form, for OCI/ai-catalog.io
interop). Registers the two new referrer types in the CEL validator
allowlist, and adds identity/owner search query types.
…tion

Adds server/identity: a Resolver registry plus dns/, did/, wellknown/, and
spiffe/ implementations that verify a claim's detached JWS against a
resolved public key (DNS TXT record, DID document, .well-known JWKS, or a
mandatory per-trust-domain SPIFFE CA bundle — no silent fallback).

Adds the SSRF-safe utils/safefetch HTTP client (https-only, blocks
private/loopback/link-local/metadata addresses, re-checked post-DNS-resolve
to close the rebinding window) used by the dns/wellknown/did resolvers.

Adds server/database/gorm's claims table (one row per record_cid + role,
composite unique index) replacing the old identity_claims/ownership_claims
split, with search filters (WithIdentities/WithOwners/*Verified) and
record-association preloading. Wires eager claim verification into the
ingest path and identity config into server startup.
…ication task

Adds client.SignAndAttachIdentityClaim/OwnershipClaim, GetIdentityStatus(ByName),
and ResolveIdentity to the Go SDK. Adds `dirctl identity claim/status/resolve`
and identity/owner search flags (--identity, --owner, --identity-verified,
--owner-verified) to `dirctl search`.

Adds reconciler/tasks/identity: periodically re-verifies identity/ownership
claim referrers (catching key rotation, expiry, and revoked SPIFFE trust
bundles that eager ingest-time verification can't observe later).

Updates the trust-model, records-validation, Go SDK, and skill-reference
docs for the new identity/ownership claim model.

This PR is purely additive: naming.v1 (NamingServiceClient, its DB API, CLI,
and reconciler task) is left fully intact and untouched. The new identity
resolve method is named ResolveIdentity (not Resolve) specifically to avoid
colliding with naming.v1's existing Client.Resolve; a couple of other
naming-clashes (a duplicated expandNameWithProtocols helper, the DatabaseAPI
interface embed) were resolved the same way, by renaming/re-adding rather
than removing anything. naming.v1's removal is a separate follow-up PR.
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

The latest Buf updates on your PR. Results from workflow Buf CI / verify-proto (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed⏩ skipped⏩ skipped✅ passedSep 8, 2026, 5:46 PM

@kperry-godaddy

Copy link
Copy Markdown
Contributor

Do we have any ETA when this will merge?

Comment on lines +604 to +622
// Handle identity subject filter with wildcard support.
if len(cfg.Identities) > 0 {
query = query.Joins("JOIN claims ic ON ic.record_cid = records.record_cid AND ic.role = ?", types.ClaimRoleIdentity)

condition, args := utils.BuildWildcardCondition("ic.subject", cfg.Identities)
if condition != "" {
query = query.Where(condition, args...)
}
}

// Handle owner subject filter with wildcard support.
if len(cfg.Owners) > 0 {
query = query.Joins("JOIN claims oc ON oc.record_cid = records.record_cid AND oc.role = ?", types.ClaimRoleOwner)

condition, args := utils.BuildWildcardCondition("oc.subject", cfg.Owners)
if condition != "" {
query = query.Where(condition, args...)
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Owner/identity search includes failed claims.

These joins filter on role only, not status, so --owner / --identity match on the claimed subject regardless of whether verification succeeded. Ingest also stores claim.GetSubject() even when verification fails (including on a subject/annotation mismatch, ingest.go:216,241).

Result: anyone can push an OwnershipClaim{subject: "did:web:acme.com"} referrer onto their own record; it's indexed as failed, but dirctl search --owner 'did:web:acme.com' still returns it. The caller only gets the safe answer if they also pass --owner-verified, and the flag help doesn't say so. --exclude-owner has the same issue.

Suggestion: add AND oc.status = 'verified' (and the same for ic) by default, or at minimum only persist the subject when it matches the record's declared annotation, and document that the unverified filter is unverified.

Comment on lines +60 to +77
records, err := t.db.GetRecords()
if err != nil {
return fmt.Errorf("get records: %w", err)
}

var identityChecked, ownershipChecked int

for _, r := range records {
cid := r.GetCid()

found, err := t.reconcileIdentity(ctx, cid, r.GetAnnotations()[corev1.AnnotationKeyIdentity])
if err != nil {
logger.Warn("Failed to reconcile identity claim", "cid", cid, "error", err)
} else if found {
identityChecked++
}

found, err = t.reconcileOwnership(ctx, cid, r.GetAnnotations()[corev1.AnnotationKeyOwner])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This task would mark every claim as failed.

db.GetRecords() never preloads Annotations (server/database/gorm/record.go:206-253; the only Preload("Annotations") is in catalog.go:153), so r.GetAnnotations() is always an empty map here. expectedSubject is therefore "", verifyClaim returns "record does not declare an identity/owner annotation" (api/identity/v1/verify.go:76-80), and the upsert overwrites the verified row ingest wrote, on every pass (every 5 minutes by default).

task_test.go uses a fakeRecord whose annotations are already populated, so it doesn't catch this. A test against the real gorm DB would.

It's also effectively off by default: unlike signature.* / indexer.*, there are no BindEnv / SetDefault entries for identity.* in reconciler/config/config.go, so it only runs if enabled in a config file.

Suggestion: get the declared subject the same way ingest does (pull the record from the store, as in declaredSubject) so both paths share one source of truth, or preload annotations in this query; add a gorm-backed test; and add env bindings/defaults for identity.enabled / identity.interval.

@kperry-godaddy

Copy link
Copy Markdown
Contributor

Two of @vivekkrishna's findings interact with the ans scheme work in #2170, so a heads-up on how I'm sequencing around them:

  1. GetRecords never preloads Annotations, so the identity task marks every claim failed on its first run. ANS-1 (refactor(dir): prepare feat/identity-add for the ans scheme (ANS-1) #2211, the first of the [Epic]: ans:// identity verification in Directory #2170 series) binds identity.enabled / identity.interval from the environment in the reconciler and the daemon (item 2 of Split the non-ANS changes out of #2152 #2171), which makes the task enableable from the environment for the first time. The samples show the task as a live enabled: false block with a note not to enable it until this is fixed here. If you would rather add the bindings in this PR yourself, say so and I'll drop that commit.

  2. The search joins match failed claims. For ans:// claims a failed row is the normal outcome of a revoked agent, so the Verified filter's semantics matter to us; I'm not changing the join, just flagging that the ans docs will describe the filter as "verified" rather than "claimed".

  3. Last referrer wins. The identity task upserts a claim row per referrer it walks, so a record with two identity-claim referrers ends with whichever one the walk visited last. Anyone who can push a referrer onto a record can therefore push a second, failing claim and flip that record's verified row to failed on the next task run. Aggregating per walk (prefer a verifying referrer, else the last failure) closes it; flagging rather than fixing since the task file is yours and under review.

Also, two base findings the ans work runs into, fixed in ANS-1 rather than here to keep this one moving: proto/buf.gen.yaml lost the agntcy/dir/naming/v1 managed go_package entry (Verify fails until #2126 removes the protos), and ./reconciler fails the pinned linter (registerTasks complexity; a dupl pair in the identity task).

@kperry-godaddy

Copy link
Copy Markdown
Contributor

One more sequencing item, on CI. task lint runs golangci-lint on whole modules (--new-from-rev is empty in CI), in the order reconciler, utils, server, client, tests, api, cli, and stops at the first red module. main is green under that run, so every finding below was introduced on this branch. Because Build needs Lint, no PR into feat/identity-add gets a Build or Test run until they are cleared, and this PR cannot merge red either. #2211 already clears reconciler (4) and utils (1, the safefetch scheme check). What remains, with the pinned 2.13.2:

server (23)

  • dupl: controller/identity.go:88 and controller/naming.go:168 (one pair); database/gorm/identity_claims_test.go:108 and :143; ingest/ingest.go:199 and :224
  • modernize: controller/identity_test.go:59, :79, :92 (strPtr to new); identity/dns/resolver.go:88 (SplitSeq); identity/spiffe/bundle.go:65 (strings.Cut)
  • staticcheck SA1019: identity/did/resolver.go:178, identity/did/resolver_test.go:98, :121 (deprecated ecdsa.PublicKey.X)
  • wsl_v5: identity/did/resolver_test.go:57, identity/dns/resolver_test.go:34, identity/wellknown/resolver_test.go:34
  • cyclop: database/gorm/record_exclude.go:70 (16 > 15); interfacebloat: types/database.go:16 (11 methods); recvcheck: database/gorm/identity_claims.go:27; wrapcheck: identity/registry.go:56; nonamedreturns: ingest/ingest_test.go:320; unparam: database/gorm/record_remove_test.go:52

api (2)

  • nestif: identity/v1/verify.go:105 (the spiffe branch of verifyClaim); wsl_v5: identity/v1/referrer_test.go:47

Could you clear these here? They are all in this PR's files, and the registry PR of the #2170 series restructures verifyClaim anyway, so the nestif can also wait for that one if you prefer.

@ramizpolic

ramizpolic commented Sep 30, 2026 •

Copy link
Copy Markdown
Member Author

Hi folks, this PR was intended only as a first step to agree on the importance and relevance. As this has been agreed, I have started the implementation in #2212 with atomic PRs that bring each piece of the implementation to it. I will keep this PR open for context, but will close it once the epic is resolved.

@kperry-godaddy please target the main branch for adding work around ANS resolver once the PR #2242 is merged
@vivekkrishna please review the same PR #2242 as it brings the SPIFFE work that you raised

@ramizpolic

Copy link
Copy Markdown
Member Author

Epic #2212 has been completed, closing this. If there are any other issues or missing features, please file a new issue.

@ramizpolic ramizpolic closed this Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants