Skip to content

Verify identity gates and provider deadlines on Axum - #1666

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

dhruv8sh wants to merge 7 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.

…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>

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

2 participants