Add authenticated S2S batch sync endpoint#558
Draft
ChristianPavilonis wants to merge 1 commit intofeature/ec-bidstream-decorationfrom
Draft
Add authenticated S2S batch sync endpoint#558ChristianPavilonis wants to merge 1 commit intofeature/ec-bidstream-decorationfrom
ChristianPavilonis wants to merge 1 commit intofeature/ec-bidstream-decorationfrom
Conversation
Implement Story 8 (#541): POST /api/v1/sync with Bearer API key auth, per-partner rate limiting, batch size cap, per-mapping validation and rejection reasons, 200/207 response semantics, tolerant Bearer parsing, and KV-abort on store unavailability.
f26c040 to
8226904
Compare
fa846e3 to
65f6c4d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /api/v1/syncS2S batch sync endpoint with Bearer-token partner auth, per-partner rate limiting, request validation, per-mapping processing, and200/207response behavior.upsert_partner_id_if_existsreturning explicit outcomes (Written,NotFound,ConsentWithdrawn,Stale) so batch sync can reject unknown hashes, block withdrawn consent, and treat stale timestamps as accepted no-ops.RateLimiter/FastlyRateLimiterand route S2S sync in the adapter with direct return (skipping EC cookie finalize middleware for non-browser traffic).Details
crates/trusted-server-core/src/ec/batch_sync.rsAuthorization: Bearer <token>PartnerStore::find_by_api_key_hash(hash_api_key(token))partner.batch_rate_limit1000), hash format, non-emptypartner_uid, requiredtimestampssc_hashto lowercase before KV lookup{ accepted, rejected, errors[] }crates/trusted-server-core/src/ec/kv.rsUpsertResultenumupsert_partner_id_if_exists(...)CAS write without auto-createcrates/trusted-server-adapter-fastly/src/main.rsPOST /api/v1/syncec_finalize_responsefor this S2S endpointValidation
cargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo test --workspace(798 tests)cd crates/js/lib && npx vitest run(282 tests)Closes