@@ -31,6 +31,9 @@ use tracing::{error, warn};
3131
3232pub static CREATE_STREAM_LOCK : Mutex < ( ) > = Mutex :: const_new ( ( ) ) ;
3333
34+ use crate :: handlers:: http:: middleware:: { CLUSTER_SECRET , CLUSTER_SECRET_HEADER } ;
35+ use crate :: parseable:: DEFAULT_TENANT ;
36+ use crate :: utils:: get_user_from_request;
3437use crate :: {
3538 handlers:: {
3639 UPDATE_STREAM_KEY ,
@@ -126,7 +129,7 @@ pub async fn put_stream(
126129 let stream_name = stream_name. into_inner ( ) ;
127130 let tenant_id = get_tenant_id_from_request ( & req) ;
128131 let _guard = CREATE_STREAM_LOCK . lock ( ) . await ;
129- let headers = PARSEABLE
132+ let mut headers = PARSEABLE
130133 . create_update_stream ( req. headers ( ) , & body, & stream_name, & tenant_id)
131134 . await ?;
132135
@@ -136,6 +139,24 @@ pub async fn put_stream(
136139 false
137140 } ;
138141
142+ if let Some ( ( _, hash) ) = CLUSTER_SECRET . get ( ) {
143+ let userid = get_user_from_request ( & req) . unwrap ( ) ;
144+ headers. insert (
145+ actix_web:: http:: header:: HeaderName :: from_static ( CLUSTER_SECRET_HEADER ) ,
146+ actix_web:: http:: header:: HeaderValue :: from_str ( hash) . unwrap ( ) ,
147+ ) ;
148+ headers. insert (
149+ actix_web:: http:: header:: HeaderName :: from_static ( "intra-cluster-tenant" ) ,
150+ actix_web:: http:: header:: HeaderValue :: from_str (
151+ tenant_id. as_deref ( ) . unwrap_or ( DEFAULT_TENANT ) ,
152+ )
153+ . unwrap ( ) ,
154+ ) ;
155+ headers. insert (
156+ actix_web:: http:: header:: HeaderName :: from_static ( "intra-cluster-userid" ) ,
157+ actix_web:: http:: header:: HeaderValue :: from_str ( & userid) . unwrap ( ) ,
158+ ) ;
159+ }
139160 sync_streams_with_ingestors ( headers, body, & stream_name, & tenant_id) . await ?;
140161
141162 if is_update {
0 commit comments