@@ -13,7 +13,7 @@ use crate::client::log_paths::{
1313use crate :: client:: sse_client:: SseEvent ;
1414use crate :: models:: { FileModel , JobModel , ResultModel , ScheduledComputeNodesModel , WorkflowModel } ;
1515
16- use crate :: client:: apis:: configuration:: TlsConfig ;
16+ use crate :: client:: apis:: configuration:: { BasicAuth , TlsConfig } ;
1717
1818use super :: api:: TorcClient ;
1919use super :: components:: {
@@ -269,12 +269,15 @@ pub struct App {
269269
270270 // TLS configuration
271271 pub tls : TlsConfig ,
272+
273+ // Authentication
274+ pub basic_auth : Option < BasicAuth > ,
272275}
273276
274277impl App {
275278 #[ allow( dead_code) ]
276279 pub fn new ( ) -> Result < Self > {
277- Self :: new_with_options ( false , 8080 , None , None , false )
280+ Self :: new_with_options ( false , 8080 , None , None , false , None )
278281 }
279282
280283 pub fn new_with_options (
@@ -283,12 +286,13 @@ impl App {
283286 database : Option < String > ,
284287 tls_ca_cert : Option < String > ,
285288 tls_insecure : bool ,
289+ basic_auth : Option < BasicAuth > ,
286290 ) -> Result < Self > {
287291 let tls = TlsConfig {
288292 ca_cert_path : tls_ca_cert. as_ref ( ) . map ( std:: path:: PathBuf :: from) ,
289293 insecure : tls_insecure,
290294 } ;
291- let client = TorcClient :: new_with_tls ( tls. clone ( ) ) ?;
295+ let client = TorcClient :: new_with_tls ( tls. clone ( ) , basic_auth . clone ( ) ) ?;
292296
293297 // In standalone mode, override the server URL to use the specified port
294298 let server_url = if standalone {
@@ -346,6 +350,7 @@ impl App {
346350 sse_thread : None ,
347351 sse_workflow_id : None ,
348352 tls,
353+ basic_auth,
349354 } ;
350355
351356 // Update client to use the correct URL
@@ -755,9 +760,12 @@ impl App {
755760 return Ok ( ( ) ) ;
756761 }
757762
758- // Create new client with updated URL
759- self . client =
760- TorcClient :: from_url_with_tls ( self . server_url_input . clone ( ) , self . tls . clone ( ) ) ?;
763+ // Create new client with updated URL, preserving authentication
764+ self . client = TorcClient :: from_url_with_tls (
765+ self . server_url_input . clone ( ) ,
766+ self . tls . clone ( ) ,
767+ self . basic_auth . clone ( ) ,
768+ ) ?;
761769 self . server_url = self . server_url_input . clone ( ) ;
762770 self . focus = Focus :: Workflows ;
763771
@@ -905,6 +913,7 @@ impl App {
905913 let mut config =
906914 crate :: client:: apis:: configuration:: Configuration :: with_tls ( self . tls . clone ( ) ) ;
907915 config. base_path = self . server_url . clone ( ) ;
916+ config. basic_auth = self . basic_auth . clone ( ) ;
908917
909918 let result = version_check:: check_version ( & config) ;
910919
@@ -2055,11 +2064,13 @@ impl App {
20552064 // Get the base URL for SSE connection
20562065 let base_url = self . server_url . clone ( ) ;
20572066 let tls = self . tls . clone ( ) ;
2067+ let basic_auth = self . basic_auth . clone ( ) ;
20582068
20592069 // Start background thread for SSE connection
20602070 let handle = std:: thread:: spawn ( move || {
20612071 let mut config = crate :: client:: apis:: configuration:: Configuration :: with_tls ( tls) ;
20622072 config. base_path = base_url;
2073+ config. basic_auth = basic_auth;
20632074
20642075 match crate :: client:: sse_client:: SseConnection :: connect ( & config, workflow_id, None ) {
20652076 Ok ( mut connection) => {
0 commit comments