Repository navigation
feat(identity): record identity/ownership verifiable claims - #2125
ramizpolic wants to merge 3 commits into
Conversation
…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.
|
The latest Buf updates on your PR. Results from workflow Buf CI / verify-proto (pull_request).
|
|
Do we have any ETA when this will merge? |
| // 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...) | ||
| } | ||
| } |
There was a problem hiding this comment.
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.
| 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]) |
There was a problem hiding this comment.
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.
|
Two of @vivekkrishna's findings interact with the
Also, two base findings the |
|
One more sequencing item, on CI. server (23)
api (2)
Could you clear these here? They are all in this PR's files, and the registry PR of the #2170 series restructures |
|
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 |
|
Epic #2212 has been completed, closing this. If there are any other issues or missing features, please file a new issue. |
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).
IdentityClaim/OwnershipClaimmessages,IdentityService(GetIdentityStatus,Resolve), and theapi/identity/v1Go 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. AddsRecord.GetIdentity/GetOwner/GetIdentityType/GetOwnerTypeannotation accessors andRecord.GetDigest(sha256:hex form, for OCI/ai-catalog.io interop).server/identityresolvers (dns/did/wellknown/spiffe) behind a commonResolverregistry, the SSRF-safeutils/safefetchHTTP client they share, a unifiedclaimsDB table (record_cid + role), and eager claim verification wired into ingest.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. anexpandNameWithProtocolshelper 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 testpass acrossapi,server,client,cli,reconciler,tests,samples/ard-over-ads.