@@ -18,6 +18,8 @@ use tokio::{sync::oneshot, task::JoinHandle, time::Duration};
18
18
use universaldb:: options:: StreamingMode ;
19
19
use universaldb:: utils:: IsolationLevel :: * ;
20
20
21
+ const X_RIVET_TOKEN : HeaderName = HeaderName :: from_static ( "x-rivet-token" ) ;
22
+
21
23
struct OutboundConnection {
22
24
handle : JoinHandle < ( ) > ,
23
25
shutdown_tx : oneshot:: Sender < ( ) > ,
@@ -226,11 +228,19 @@ async fn outbound_handler(
226
228
) )
227
229
} )
228
230
. collect ( ) ;
229
- let mut es = sse:: EventSource :: new ( client. get ( url) . headers ( headers) ) ?;
231
+
232
+ let mut req = client. get ( url) . headers ( headers) ;
233
+
234
+ // Add admin token if configured
235
+ if let Some ( auth) = ctx. config ( ) . auth {
236
+ req = req. header ( X_RIVET_TOKEN , & auth. admin_token ) ;
237
+ }
238
+
239
+ let mut source = sse:: EventSource :: new ( req) ?;
230
240
let mut runner_id = None ;
231
241
232
242
let stream_handler = async {
233
- while let Some ( event) = es . next ( ) . await {
243
+ while let Some ( event) = source . next ( ) . await {
234
244
match event {
235
245
Ok ( sse:: Event :: Open ) => { }
236
246
Ok ( sse:: Event :: Message ( msg) ) => {
@@ -269,7 +279,7 @@ async fn outbound_handler(
269
279
}
270
280
271
281
// Continue waiting on req while draining
272
- while let Some ( event) = es . next ( ) . await {
282
+ while let Some ( event) = source . next ( ) . await {
273
283
match event {
274
284
Ok ( sse:: Event :: Open ) => { }
275
285
Ok ( sse:: Event :: Message ( msg) ) => {
0 commit comments