Skip to content

Commit 9b18c95

Browse files
Fix post-rebase edge cookie integration issues
1 parent b533e13 commit 9b18c95

6 files changed

Lines changed: 11 additions & 30 deletions

File tree

crates/trusted-server-adapter-fastly/src/main.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,6 @@ async fn route_request(
299299
false,
300300
)
301301
}
302-
(Method::POST, "/admin/partners/register")
303-
| (Method::POST, "/_ts/admin/partners/register") => (
304-
require_partner_store(settings).and_then(|store| handle_register_partner(&store, req)),
305-
false,
306-
),
307302
(Method::GET, "/_ts/api/v1/identify") => (
308303
// Bot gate is intentionally write-only in this PR. `/identify` reads
309304
// remain gated by bearer auth + consent, even when request-classification
@@ -330,6 +325,7 @@ async fn route_request(
330325
kv_graph.as_ref(),
331326
registry_ref,
332327
&ec_context,
328+
runtime_services,
333329
req,
334330
)
335331
.await,
@@ -522,18 +518,6 @@ fn finalize_response(settings: &Settings, geo_info: Option<&GeoInfo>, response:
522518
}
523519
}
524520

525-
/// Constructs a `PartnerStore` from settings, or returns 503 if the
526-
/// `partner_store` config is not set.
527-
fn require_partner_store(settings: &Settings) -> Result<PartnerStore, Report<TrustedServerError>> {
528-
let store_name = settings.ec.partner_store.as_deref().ok_or_else(|| {
529-
Report::new(TrustedServerError::KvStore {
530-
store_name: "ec.partner_store".to_owned(),
531-
message: "ec.partner_store is not configured".to_owned(),
532-
})
533-
})?;
534-
Ok(PartnerStore::new(store_name))
535-
}
536-
537521
/// Constructs a `KvIdentityGraph` from settings, or returns 503 if the
538522
/// `ec_store` config is not set.
539523
fn require_identity_graph(

crates/trusted-server-core/src/auction/endpoints.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use crate::ec::registry::PartnerRegistry;
1616
use crate::ec::EcContext;
1717
use crate::error::TrustedServerError;
1818
use crate::openrtb::{Eid, Uid};
19+
use crate::platform::RuntimeServices;
1920
use crate::settings::Settings;
2021

2122
use super::formats::{convert_to_openrtb_response, convert_tsjs_to_auction_request};
@@ -45,6 +46,7 @@ pub async fn handle_auction(
4546
kv: Option<&KvIdentityGraph>,
4647
registry: Option<&PartnerRegistry>,
4748
ec_context: &EcContext,
49+
services: &RuntimeServices,
4850
mut req: Request,
4951
) -> Result<Response, Report<TrustedServerError>> {
5052
// Parse request body

crates/trusted-server-core/src/auction/test_support.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,20 @@ use std::sync::LazyLock;
33
use fastly::Request;
44

55
use super::AuctionContext;
6-
use crate::platform::{test_support::noop_services, ClientInfo, RuntimeServices};
6+
use crate::platform::{test_support::noop_services, RuntimeServices};
77
use crate::settings::Settings;
88

99
static TEST_SERVICES: LazyLock<RuntimeServices> = LazyLock::new(noop_services);
1010

1111
pub(crate) fn create_test_auction_context<'a>(
1212
settings: &'a Settings,
1313
request: &'a Request,
14-
client_info: &'a ClientInfo,
1514
timeout_ms: u32,
1615
) -> AuctionContext<'a> {
1716
let services: &'static RuntimeServices = &TEST_SERVICES;
1817
AuctionContext {
1918
settings,
2019
request,
21-
client_info,
2220
timeout_ms,
2321
provider_responses: None,
2422
services,

crates/trusted-server-core/src/ec/cookies.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ mod tests {
340340
assert_eq!(
341341
cookie_str,
342342
format!(
343-
"{}=; Domain=.{}; Path=/; Secure; SameSite=Lax; Max-Age=0",
343+
"{}=; Domain=.{}; Path=/; Secure; SameSite=Lax; Max-Age=0; HttpOnly",
344344
COOKIE_TS_EC, settings.publisher.domain,
345345
),
346346
"expiry cookie should retain the same security attributes as the live cookie"

crates/trusted-server-core/src/error.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ pub enum TrustedServerError {
2626
#[display("Configuration error: {message}")]
2727
Configuration { message: String },
2828

29-
/// Insecure placeholder configuration was detected.
30-
#[display("Insecure default value configured for {field}")]
31-
InsecureDefault { field: String },
32-
3329
/// Auction orchestration error.
3430
#[display("Auction error: {message}")]
3531
Auction { message: String },
@@ -117,9 +113,7 @@ impl IntoHttpResponse for TrustedServerError {
117113
match self {
118114
Self::Auction { .. } => StatusCode::BAD_GATEWAY,
119115
Self::BadRequest { .. } => StatusCode::BAD_REQUEST,
120-
Self::Configuration { .. } | Self::InsecureDefault { .. } | Self::Settings { .. } => {
121-
StatusCode::INTERNAL_SERVER_ERROR
122-
}
116+
Self::Configuration { .. } | Self::Settings { .. } => StatusCode::INTERNAL_SERVER_ERROR,
123117
Self::Gam { .. } => StatusCode::BAD_GATEWAY,
124118
Self::GdprConsent { .. } => StatusCode::BAD_REQUEST,
125119
Self::InvalidHeaderValue { .. } => StatusCode::BAD_REQUEST,

crates/trusted-server-core/src/integrations/registry.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,11 @@ impl IntegrationRegistry {
674674
}
675675

676676
// Set EC ID header on the request so integrations can read it.
677+
// Remove any caller-supplied invalid value rather than forwarding it.
677678
if let Some(ec_id) = ec_context.ec_value() {
678679
req.set_header(HEADER_X_TS_EC, ec_id);
680+
} else {
681+
req.remove_header(HEADER_X_TS_EC);
679682
}
680683

681684
Some(proxy.handle(settings, req).await)
@@ -1271,7 +1274,7 @@ mod tests {
12711274
// Provide an existing EC via header (client IP is unavailable in
12721275
// the test environment, so generation would fail).
12731276
let mut req = Request::get("https://test-publisher.com/integrations/test/ec");
1274-
req.set_header("x-ts-ec", "test-ec-id-from-header");
1277+
req.set_header("x-ts-ec", format!("{}.HdrEc1", "a".repeat(64)));
12751278
let mut ec_context =
12761279
EcContext::read_from_request(&settings, &req).expect("should read EC context");
12771280

@@ -1388,7 +1391,7 @@ mod tests {
13881391

13891392
let mut req =
13901393
Request::post("https://test-publisher.com/integrations/test/ec").with_body("test body");
1391-
req.set_header("x-ts-ec", "test-ec-id-from-header");
1394+
req.set_header("x-ts-ec", format!("{}.HdrEc1", "a".repeat(64)));
13921395
let mut ec_context =
13931396
EcContext::read_from_request(&settings, &req).expect("should read EC context");
13941397

0 commit comments

Comments
 (0)