Skip to content

Verify identity gates and provider deadlines on Axum - #1666

Open
dhruv8sh wants to merge 17 commits into
feat/1598-ec-route-fastlyfrom
feat/1581-axum-identity-acceptance
Open

dhruv8sh wants to merge 17 commits into
feat/1598-ec-route-fastlyfrom
feat/1581-axum-identity-acceptance

Conversation

@dhruv8sh

@dhruv8sh dhruv8sh commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Changes

File Change
crates/trusted-server-core/src/test_support/identity_conformance.rs New verify_identity_gates. SID-1: the configured _pubcid cookie is read and sharedId is not. SID-2: _pubcid_optout stops reading the browser's SharedID and keeps it out of the bid request. SID-6 and WB-3: with Purpose 1 granted and Purpose 4 denied, no SharedID is set, expired or sent, whether the browser cookie is absent or different, and a browser SharedID is not read into a record that has none. The Prebid fixture comes from one prebid_fixture(storage_type) helper, so the html5 case differs from the cookie cases only in storage type. WB-3: Purpose 1 denied expires _pubcid and _pubcid_cst, and html5 storage gets no server-made SharedID. ID-9: a cross-site POST and a GET call no provider and mint nothing. Each case has a control that shows the capture works: a bid request that does carry SharedID, and a POST that does call ID5. To support this, ApiRequest can turn on an ID5 provider, a capture bidder and html5 storage, applied by the new configure_api_request; ApiObservation records the exchange's outbound requests; and the new tcf_purposes_cookie sets Purposes 1 and 4 separately.
crates/trusted-server-adapter-axum/src/identity_conformance.rs Runs verify_identity_gates. ID-4: ID5 answering within the deadline puts its UID in the record and the mirror cookie; one past the deadline is skipped and the response goes out by the deadline. ID-9: after a grant with no EC whose page-phase ID5 lookup is slower than the deadline, the withdrawal expires the identity cookies and leaves a withdrawn record with no late UID. With an after_response provider, a HoldingScheduler holds follow-up tasks: a grant with no EC schedules one that calls no provider, and a returning reader's follow-up held across a withdrawal calls no provider and stores no UID, with a control run (no withdrawal) that does call ID5 and store its UID. Tests that assert no late UID run the held tasks first. The provider setup is shared with the existing redirect test.
crates/trusted-server-adapter-fastly/src/identity_conformance.rs Runs verify_identity_gates and applies configure_api_request.

Closes

Refs #1581. Safari's one-year Max-Age has been verified by hand. These stay open, both in the page script (#1622):

Spec

Spec: server-side identity on every adapter: ID-4, ID-7, ID-9, WB-3, WB-4, SID-1, SID-2 and SID-6 (plan ID A10). Checked against 9ea63979a: compliant for what this PR covers, with the gaps above.

Test plan

  • cargo test-axum and cargo test-fastly (Fastly 4296 passed; Axum 128 passed, at 59a5eb5d8)
  • cargo clippy-fastly && cargo clippy-axum
  • cargo fmt --all -- --check
  • Doctests for tcf_consent_cookie and tcf_purposes_cookie (host target)
  • JS tests and format (no JS changes)
  • Manual Safari check of Max-Age
  • Mutation checks. Each of these production changes fails a named test: treating html5 as cookie storage, reading sharedId instead of the configured cookie, never reading the configured cookie, ignoring _pubcid_optout in the SharedID cookie handling or in the auction, letting Purpose 1 alone permit EIDs, keeping SharedID when Purpose 1 is denied, calling providers on an EC GET, skipping page-lookup collection on Axum, storing EID updates without the consent gate (the SID-6 case on a record without SharedID), and dropping the live-row consent check from both after-response gates (after_response_lookups_allowed and the coordinator; either one alone still blocks the lookup).

Notes for review

  • The withdrawal race. ID-9 pictures a withdrawal arriving while a grant with no EC and slow providers is in flight. A grant with an after_response provider does schedule a follow-up task after its response, so the server has that window. But follow-ups run only for an EC that existed before the request (after_response_lookups_allowed), so the grant's follow-up never calls a provider and no late UID can follow the withdrawal; follow_up_from_a_grant_with_no_ec_calls_no_provider shows it. For a returning reader, whose follow-up does run, the task re-reads the row when it runs: held_follow_up_for_a_returning_reader_calls_no_provider_after_a_withdrawal holds it across a withdrawal, and held_follow_up_for_a_returning_reader_stores_the_uid is the control. Page-phase lookups finish or are skipped before the grant's response. In the browser, the script also queues the withdrawal behind the grant.
  • Two opt-out gates. _pubcid_optout is enforced both in the SharedID cookie handling and separately in the auction (auction/endpoints.rs). The new tests cover both.
  • Outbound requests. ApiObservation::outbound holds every outbound request the exchange made, including the one to the publisher origin; origin_requests is unchanged.

Checklist

  • Feature PRs: spec linked above, ending in a review log of two or more agent review rounds
  • Changes follow AGENTS.md conventions
  • No unwrap() in production code — use expect("should ...")
  • Uses log macros (not println!)
  • New code has tests
  • No secrets or credentials committed

The shared conformance suite gains verify_identity_gates, run by the Axum
and Fastly runners: the configured _pubcid cookie is read and a cookie
named sharedId is not (SID-1); _pubcid_optout stops reading the browser's
SharedID and keeps it out of the bid request (SID-2); Purpose 4 denied with
Purpose 1 granted keeps SharedID out of the record, the response and the
bid request (SID-6, WB-3); Purpose 1 denied expires SharedID and its
companion, and html5 storage gets no server-made SharedID (WB-3); and a
cross-site POST or a GET calls no provider (ID-9). Each case has a control
that shows the capture works. Requests can now turn on an ID5 provider, a
capture bidder and html5 storage, and observations record the exchange's
outbound requests.

The Axum runner adds ID5 within and past the page-lookup deadline (ID-4)
and a withdrawal after a grant whose lookup is slower than the deadline
(ID-9).
…haredID

The Axum provider fixtures use the shared Chrome User-Agent fixture, and
the Purpose 4 gates also check that the EC route answers without sharedId.
@dhruv8sh dhruv8sh linked an issue Nov 25, 2026 that may be closed by this pull request
18 of 21 tasks
Run held after-response tasks before asserting no late UID, and require the within-deadline response to be released before the deadline. Replace the held follow-up test, which passed with or without the withdrawal because follow-ups never run for a newly minted EC, with a grant case and a returning-reader case that has a no-withdrawal control.

Check the status of the Purpose 1 only POST and of the cross-site POST and GET, build the cross-site POST from the control with only its Origin changed, and document what origin_requests counts.

Signed-off-by: dhruv8sh <dhruv8sh@proton.me>
@dhruv8sh

Copy link
Copy Markdown
Collaborator Author

#1581's acceptance criteria that this PR doesn't add tests for, because PRs below it in the stack already cover them. Most of those tests are in the shared conformance suite, which the Axum runner here executes, so they already run on Axum:

Criterion Covered by Where
ID-7: a non-browser JA4 behind a browser User-Agent creates no record; current Chrome, Safari and Firefox JA4s still create one; no trusted JA4 does not block #1661 Shared navigation scenarios ContradictingJa4, BrowserEngineMismatch, CurrentFirefox, CurrentSafari, MissingTrustedJa4
ID-9: the EC route refuses a client that ID-7 refuses #1662 Core ec/app/route_tests.rs (a Python JA4 behind a Chrome User-Agent mints nothing)
ID-9: a consented POST with no ts-ec creates the record and sets ts-ec and the SharedID cookie #1646, #1662 verify_http_contract (EC POST creates the record and issues the persisted SharedID, a UUID v4)
ID-9: the JSON omits a non-mirrored partner's ID, a vendor-denied ID and an expired ID #1646 verify_http_contract (mirror revocation and "never disclose a non-mirrored partner UID")
ID-9: an unchanged returning reader gets no Set-Cookie #1662 verify_http_contract (yesterday's mirror is kept, with no identity cookie re-set)
ID-9: grant A, withdrawal B, grant C reach the server in order (server side) #1662 verify_http_contract (B tombstones A's record; C mints a new EC as a first consent)
ID-9: Safari keeps the one-year Max-Age Manual Verified by hand on Fastly; the cookies' Max-Age=31536000 is asserted in #1662
WB-3: SharedID cookie attributes, creation as a UUID v4, none for a reader with _pubcid_optout #1624, #1662 verify_http_contract; ec/sharedid.rs unit tests
WB-3: Purpose 1 denied or _pubcid_optout expires both cookies #1624 (unit level) ec/sharedid.rs (denied_ec_consent_or_opt_out_expires_both); this PR adds the Purpose 1 case through both adapters
WB-3: an equal cookie with a consistent <name>_cst gives no Set-Cookie; a missing or different one re-sets only the companion #1624 ec/sharedid.rs (equal_cookie_with_consistent_companion_is_unchanged, equal_cookie_with_missing_or_different_companion_sets_only_the_companion)
WB-4: an ID with no stated expiry is mirrored with an expiry within 30 days #1662 verify_http_contract

These stay with the page script, #1622 (T20):

  • ID-9 browser side: a withdrawal leaves no ID in Prebid, and the script queues consent changes in order.
  • SID-2: an opt-out stored only in localStorage, which the script copies into the _pubcid_optout cookie.

This PR adds what was missing on top of those: ID-4 on Axum, verify_identity_gates (SID-1, SID-2's cookie opt-out, SID-6, WB-3 with html5 storage and with Purpose 4 denied, and ID-9's "a cross-site POST or a GET calls no provider") for both adapters, and the ID-9 follow-up tests across a withdrawal.

@dhruv8sh
dhruv8sh marked this pull request as ready for review November 25, 2026 12:34

@ChristianPavilonis ChristianPavilonis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The shared cases give Axum and Fastly the same identity checks, and the scripted clock makes the Axum deadline tests deterministic. All 10 Axum identity conformance tests passed locally. Approved with non-blocking comments on what a few assertions prove and how the fixtures are maintained.

dhruv8sh and others added 4 commits December 1, 2026 10:53
…feat/1581-axum-identity-acceptance

Signed-off-by: dhruv8sh <dhruv8sh@proton.me>

# Conflicts:
#	crates/trusted-server-adapter-axum/src/identity_conformance.rs
#	crates/trusted-server-adapter-fastly/src/identity_conformance.rs
#	crates/trusted-server-core/src/test_support/identity_conformance.rs
Check user.ext.eids too in the SharedID absence cases, require both opt-out expiries, prove ID5 overlaps a delayed origin fetch, assert follow-up outcomes instead of queue sizes, and count publisher forwarding apart from provider traffic. Share the ID5 provider and partner fixtures between core and Axum.

Signed-off-by: dhruv8sh <dhruv8sh@proton.me>
PR #1662's new head brings the cascaded owner review fixes from #1525, #1526, #1488, #1489, #1639, #1531, #1532, #1615, #1637, #1533, #1536, #1535, #1537, #1538 and #1646.

The merge is textually clean but did not compile, so this link carries a semantic fix.

crates/trusted-server-core/src/test_support/identity_conformance.rs: #1646 added a malformed-consent check that reads ApiObservation.origin_requests, which #1666 replaced with the full outbound request list. The resolution asserts that the outbound list is empty, as #1666 does for the other local EC route answers.
PR #1662's new head brings wave B: #1506's merge of main ab5c24f (#1501, js_asset_proxy rewriter ordering) and its repin of EdgeZero to rc/identity 8a73c0978806, carried up through the chain. The merge is clean. Cargo.lock changes only the 10 EdgeZero package sources, now at 8a73c097; the codegen crate's nested Cargo.lock is unchanged.
aram356 added a commit that referenced this pull request Dec 1, 2026
One octopus merge of the round 12 tips into rc/identity c3e3366. It is a single octopus because the RC already holds every sibling's old head, so each tip's new head merges in alongside the others rather than as a chain of merges. The tree is the automatic merge of the RC and all tips, with no resolution: every tip pair, their union and the merge into the RC are clean.

Tips, in parent order after the RC:

- PR #1503 at 4225024
- PR #1653 at 4bd4903
- PR #1654 at 95cf3e8
- PR #1655 at 05c509d
- PR #1622 at afe5217
- PR #1660 at c1a05d7
- PR #1666 at 108b122
- PR #1659 at 5fb8190
- PR #1709 at 6d152f6
- PR #1710 at dcceeee
- PR #1713 at cae7801
- PR #1557 at 302e972

PR #1659 sits above PR #1718, so it carries PR #1714, PR #1717 and PR #1718.
@aram356

aram356 commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Round 12 identity realignment: rc/identity is now at db7dce634, and EdgeZero is pinned to its rc/identity at 8a73c097. This branch fast-forwarded from c7f4867d2 to 108b1228d:

Each merge message says what it carries and how any conflict was resolved.

PR #1662's new head brings #1535's owner fix that keeps mirrored GPP consent through transient CMP not-ready states (#1678), #1535's move of the consent-update test host to publisher.example.com for the URL-host lint and #1540's allow-domain marks on the deployment guide's reference links. The merge is clean.
aram356 added a commit that referenced this pull request Dec 2, 2026
It brings #1535's owner fix that keeps mirrored GPP consent through transient CMP not-ready states (#1678), #1535's and #1540's URL-host lint fixes, and #1622's move of the new GPP bridge tests into its split test file, carried up to every tip: #1653, #1654, #1655, #1622, #1660, #1666, #1659, #1709, #1710, #1713 and #1557. #1503 is already contained. The octopus tree is the conflict-free union of the tips.
PR #1662's new head brings #1506's move of the five auction endpoint test requests from test-publisher.com to publisher.example.com, for the URL-host lint. The merge is clean.
aram356 added a commit that referenced this pull request Dec 2, 2026
It brings #1666's cascade merge of #1506's auction endpoint test host fix.

@prk-Jr prk-Jr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Summary

Tests-only PR that fills #1581's acceptance gaps through the real adapters: verify_identity_gates (SID-1, SID-2, SID-6, WB-3, ID-9 "calls no provider") runs on both Axum and Fastly, and Axum gets ID-4 deadline tests and ID-9 withdrawal tests with a held after-response scheduler. Christian's R2–R9 are all addressed in c7f4867d2; everything after it is stack merges. I found nothing blocking.

Non-blocking

👍 praise

  • The deadline tests discriminate and are deterministic. They run on the scripted test clock, so the timing assertions don't depend on wall time.
    • The within-deadline case asserts held < IDENTITY_BUDGET / 2, and running the origin fetch and ID5 one after the other lands exactly on that bound. To check this, I made dispatch_with_response await the publisher response before starting the lookups. That made page_lookup_within_the_deadline_reaches_the_record_and_the_mirror_cookie fail at the overlap assertion, along with both redirect-cancel tests.
    • The 12 Axum identity tests passed 25 times in a row.
  • The held-scheduler tests reach the gate they describe. Forcing after_response_lookups_allowed to return true fails three tests: follow_up_from_a_grant_with_no_ec_calls_no_provider, the returning-reader control and the withdrawal case. So the test catches a newly minted EC getting a follow-up, rather than passing because nothing was scheduled.

CI Status

  • 32 checks pass, including cargo test, cargo test (axum native), cargo test (cross-adapter parity), cargo fmt, format-docs and vitest.
  • integration tests and integration tests (Fastly EC lifecycle) are still pending.
  • The cargo fmt job runs the clippy aliases in CI. Locally as well, cargo clippy-axum and core + Fastly clippy on wasm32-wasip1 with --all-targets --all-features -D warnings are clean.

PR #1662's new head (14749b9) moves the consent-string comment in identity_conformance.rs from above route_json back to verify_ec_route_fixture, the function it describes.

crates/trusted-server-core/src/test_support/identity_conformance.rs: #1666 added its fixture helpers between that comment's old place and route_json. The resolution keeps #1666's helpers and drops the comment there, so it appears once, above verify_ec_route_fixture.
PR #1662's new head brings #1506's repin of EdgeZero to rc/identity ef5cbf30, which renames Fastly backends to ez_b31v2_* and moves the yanked pin-project-lite, chacha20 and spin, #1625's shared Wrangler installer for CI, #1639's pull reserve boundary check and wording, #1613's conformance doc alignment, #1616's certificate policy and pull-sync fixture corrections, #1617's preserved startup diagnostics and hardened runtime checks, #1635's complete startup evidence in native fixtures, #1637's shared readable non-Unicode Geo fixture, #1627's Spin store reads and retained runtime coverage, #1535's Sourcepoint consent mirror deduplication and consent update coverage, #1636's stronger after-response body and drain checks, #1626's enforcement of stored and carried provider opt-outs, #1656's strict browser gate wording and #1661's grouped QUIC JA4 fixture. The merge is clean. Cargo.lock changes only the EdgeZero package sources (now ef5cbf30) and the yanked pin-project-lite, chacha20 and spin; the codegen crate's nested Cargo.lock is unchanged.
aram356 added a commit that referenced this pull request Dec 3, 2026
PR #1503 at 1d51b78: Add ts ec show and ts ec eids admin diagnostic commands
PR #1653 at f217902: Clarify and verify the Axum local config handoff
PR #1654 at e4e68bb: Verify pending record writes drain within shutdown grace
PR #1655 at 7d0cdb2: Configure EC lifetime and renew it on eligible visits (DEC-13)
PR #1659 at bd707f2: Verify geo consent paths on Axum and Fastly
PR #1660 at 87c52cd: Retry an after-response write that loses its CAS
PR #1666 at b1d7062: Verify identity gates and provider deadlines on Axum
PR #1710 at 3d33359: Apply pull-sync consent checks to identify
PR #1557 at 3982143: Carry Sourcepoint TCF consent to Trusted Server
PR #1667 at f9ac6bb: Present a client certificate on auction providers that set mtls
PR #1607 at b3a0b09: Send the resolved client IP to the publisher origin
PR #1709 at 635f06a: Keep the EC out of bid request IDs and gate user.id on EID consent
PR #1713 at e5f4d05: Apply consent rules to first-party click redirects
PR #1622 at dd2ee39: Report CMP consent to the EC route and merge its answer into Prebid
@aram356

aram356 commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

Round 15 identity realignment: rc/identity is now at 391a08578, and EdgeZero is pinned to its rc/identity at ef5cbf308. This branch fast-forwarded from b33c5b863 to b1d7062c9:

The first link here merges #1662's 14749b9a6, which moved a comment in identity_conformance.rs to where this PR adds helpers. It keeps the helpers, and the comment now appears once, above verify_ec_route_fixture.

Each merge message says what it carries and how any conflict was resolved.

Carries #1533's Axum startup-test port fix (779e446) and nothing
else. Owner commits pushed to other chain PRs since round 15 come in
with the next round.
@aram356

aram356 commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

Cascade of #1533's Axum startup-test port fix (779e44673): adfa67b59 merges it into this PR. There were no conflicts and nothing else changed. The fix moves free_loopback_port in crates/trusted-server-adapter-axum/tests/routes.rs below the ephemeral port range, and #1533's note has the details. Owner commits pushed to other chain PRs since round 15 come in with the next round. rc/identity is now 62f8e41e2.

@aram356

aram356 commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

Merged #1627's runtime KV removal (7c2b84f45) into this branch as d18a5aeb7, on top of adfa67b59.

At the maintainer's request, that commit removes the generic runtime KV store trusted_server_runtime_kv. Nothing reads or writes it, and the managed Fastly deploy made every service provision and pay for it. edgezero.toml and the Fastly Hooks::stores() now declare only trusted_server_kv, and RuntimeServices::kv_store() is unavailable on every adapter.

Only that commit was merged, not the base branch's new head. Conflicts were resolved in edgezero.toml, the Fastly Hooks::stores() in app.rs, fastly.toml, the Viceroy template, the integration tests' config.rs, trusted-server.example.toml, docs/guide/architecture.md and docs/guide/edgezero.md. Only trusted_server_kv stays declared, this branch's record-store comment and local seeds are kept, and the runtime-KV lines are dropped. The Axum README and docs/guide/axum-dev.md keep this branch's Axum wording.

Checks on this head: no reference to the removed store remains and cargo fmt --check passes; clippy-fastly, clippy-axum, clippy-cloudflare and clippy-spin-native pass. rc/identity (b9dc3153e) passed the full CI gate list with the removal.

PR #1662's new head brings #1487's change that strips `ts-eids` from publisher-origin requests unless the operator opts in and #1646's fix that preserves filter headers through identity finalization. The merge is clean.
aram356 added a commit that referenced this pull request Dec 3, 2026
PR #1503 at 6a8797e: Add ts ec show and ts ec eids admin diagnostic commands
PR #1557 at a435778: Carry Sourcepoint TCF consent to Trusted Server
PR #1607 at 07086f2: Send the resolved client IP to the publisher origin
PR #1627 at 5b7fc3d: Wire declared stores and document unsupported Axum KV
PR #1636 at d838931: Drain Axum after-response identity tasks on SIGTERM
PR #1653 at 5b86d9b: Clarify and verify the Axum local config handoff
PR #1654 at be495b3: Verify pending record writes drain within shutdown grace
PR #1655 at 888c5f1: Configure EC lifetime and renew it on eligible visits (DEC-13)
PR #1659 at 7b1d4a7: Verify geo consent paths on Axum and Fastly
PR #1660 at 64a1baa: Retry an after-response write that loses its CAS
PR #1667 at 1359722: Present a client certificate on auction providers that set mtls
PR #1709 at bc43a3e: Keep the EC out of bid request IDs and gate user.id on EID consent
PR #1710 at dc728a1: Apply pull-sync consent checks to identify
PR #1713 at ffa7597: Apply consent rules to first-party click redirects
PR #1722 at 070e2b0: Use applicable GPP sections from the CMP instead of header sections

PR #1666 at 4720b0b (Verify identity gates and provider deadlines on Axum) arrives through #1659, and PR #1622 at c878e6e (Report CMP consent to the EC route and merge its answer into Prebid) arrives through #1722. Every other chain PR arrives through the tips above. The tree is the conflict-free union of these tips and carries no resolution of its own.
@aram356

aram356 commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

Round 17 identity realignment: rc/identity is now at 0ed862633, and EdgeZero stays pinned to its rc/identity at ef5cbf308. This branch fast-forwarded from d18a5aeb7 to 4720b0bec:

Each merge message says what it carries and how any conflict was resolved.

@aram356

aram356 commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

Merged #1614's /_ts/ local answers (48930c270) into this branch as 28e333836, on top of 4720b0bec.

Trusted Server owns the /_ts/ namespace (#1740). A request for /_ts or any /_ts/ path that no route handles now gets a local 404 on Fastly, Axum, Cloudflare and Spin, and never reaches the publisher origin. The path is matched after percent-decoding. Paths outside the namespace, such as /_tsx or /articles/_ts/x, still go to the publisher origin, and every routed /_ts/ path answers as before.

This merge takes #1662's new head (1e8c9997f), which carries 48930c270 and nothing else new to this branch. It was clean.

Checks on this head: no conflict markers; cargo fmt --all -- --check passes; the merge adds exactly #1614's change to this branch's files; it merges cleanly with every lower head in its stack; clippy-fastly, clippy-axum, clippy-cloudflare and clippy-spin-native pass. rc/identity (e72407155) passed the full CI gate list with the change.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Identity features pass on Axum from the shared app

4 participants