@@ -14,7 +14,6 @@ use rivetkit_shared_types::serverless_metadata::{
1414} ;
1515use serde:: Serialize ;
1616use serde_json:: json;
17- use subtle:: ConstantTimeEq ;
1817use tokio:: sync:: { Mutex as TokioMutex , mpsc} ;
1918use tokio_util:: sync:: CancellationToken ;
2019
@@ -93,10 +92,6 @@ struct InvalidRequest {
9392 reason : String ,
9493}
9594
96- #[ derive( rivet_error:: RivetError , Serialize ) ]
97- #[ error( "auth" , "forbidden" , "Forbidden." ) ]
98- struct Forbidden ;
99-
10095#[ derive( rivet_error:: RivetError , Serialize ) ]
10196#[ error(
10297 "config" ,
@@ -358,17 +353,27 @@ impl CoreServerlessRuntime {
358353 }
359354
360355 fn validate_start_headers ( & self , headers : & StartHeaders ) -> Result < ( ) > {
361- if let Some ( expected_token) = & self . settings . configured_token {
362- let Some ( received_token) = & headers. token else {
363- return Err ( Forbidden . build ( ) ) ;
364- } ;
365- if !constant_time_eq ( expected_token, received_token) {
366- return Err ( Forbidden . build ( ) ) ;
367- }
368- }
356+ // TODO: pegboard-outbound does not currently auth the /start endpoint,
357+ // so the incoming `x-rivet-token` does not match `config.token`
358+ // (which is the user's API token, not a shared pool secret). Re-enable
359+ // once the envoy-era serverless pool carries a dedicated shared secret
360+ // in its configured headers.
361+ // if let Some(expected_token) = &self.settings.configured_token {
362+ // let Some(received_token) = &headers.token else {
363+ // return Err(Forbidden.build());
364+ // };
365+ // if !constant_time_eq(expected_token, received_token) {
366+ // return Err(Forbidden.build());
367+ // }
368+ // }
369369
370370 if self . settings . validate_endpoint {
371371 if !endpoints_match ( & headers. endpoint , & self . settings . configured_endpoint ) {
372+ tracing:: warn!(
373+ configured_endpoint = %self . settings. configured_endpoint,
374+ received_endpoint = %headers. endpoint,
375+ "serverless start rejected: endpoint mismatch" ,
376+ ) ;
372377 return Err ( EndpointMismatch {
373378 expected : self . settings . configured_endpoint . clone ( ) ,
374379 received : headers. endpoint . clone ( ) ,
@@ -377,6 +382,11 @@ impl CoreServerlessRuntime {
377382 }
378383
379384 if headers. namespace != self . settings . configured_namespace {
385+ tracing:: warn!(
386+ configured_namespace = %self . settings. configured_namespace,
387+ received_namespace = %headers. namespace,
388+ "serverless start rejected: namespace mismatch" ,
389+ ) ;
380390 return Err ( NamespaceMismatch {
381391 expected : self . settings . configured_namespace . clone ( ) ,
382392 received : headers. namespace . clone ( ) ,
@@ -464,10 +474,6 @@ fn optional_header(headers: &HashMap<String, String>, name: &str) -> Option<Stri
464474 headers. get ( name) . filter ( |value| !value. is_empty ( ) ) . cloned ( )
465475}
466476
467- fn constant_time_eq ( expected : & str , received : & str ) -> bool {
468- bool:: from ( expected. as_bytes ( ) . ct_eq ( received. as_bytes ( ) ) )
469- }
470-
471477fn cors_headers ( req : & ServerlessRequest ) -> HashMap < String , String > {
472478 let origin = req
473479 . headers
0 commit comments