@@ -68,6 +68,7 @@ pub struct Config {
6868 pub history_url : Url ,
6969 pub relayer_urls : Vec < Url > ,
7070 pub publish_keypair_path : PathBuf ,
71+ pub authorization_token : Option < String > ,
7172 #[ serde( with = "humantime_serde" , default = "default_publish_interval" ) ]
7273 pub publish_interval_duration : Duration ,
7374 #[ serde( with = "humantime_serde" , default = "default_symbol_fetch_interval" ) ]
@@ -292,13 +293,22 @@ pub fn lazer_exporter(config: Config, state: Arc<state::State>) -> Vec<JoinHandl
292293 let pubkey_base64 = BASE64_STANDARD . encode ( signing_key. verifying_key ( ) . to_bytes ( ) ) ;
293294 tracing:: info!( "Loaded Lazer signing key; pubkey in base64: {pubkey_base64}" ) ;
294295
296+ let authorization_token = if let Some ( authorization_token) = config. authorization_token . clone ( )
297+ {
298+ // If authorization_token is configured, use it.
299+ authorization_token
300+ } else {
301+ // Otherwise, use the base64 pubkey.
302+ pubkey_base64
303+ } ;
304+
295305 // can safely drop first receiver for ease of iteration
296306 let ( relayer_sender, _) = broadcast:: channel ( RELAYER_CHANNEL_CAPACITY ) ;
297307
298308 for url in config. relayer_urls . iter ( ) {
299309 let mut task = RelayerSessionTask {
300310 url : url. clone ( ) ,
301- token : pubkey_base64 . clone ( ) ,
311+ token : authorization_token . clone ( ) ,
302312 receiver : relayer_sender. subscribe ( ) ,
303313 } ;
304314 handles. push ( tokio:: spawn ( async move { task. run ( ) . await } ) ) ;
@@ -725,6 +735,7 @@ mod tests {
725735 history_url : Url :: parse ( "http://127.0.0.1:12345" ) . unwrap ( ) ,
726736 relayer_urls : vec ! [ Url :: parse( "http://127.0.0.1:12346" ) . unwrap( ) ] ,
727737 publish_keypair_path : PathBuf :: from ( private_key_file. path ( ) ) ,
738+ authorization_token : None ,
728739 publish_interval_duration : Duration :: from_secs ( 1 ) ,
729740 symbol_fetch_interval_duration : Duration :: from_secs ( 60 * 60 ) ,
730741 } ;
0 commit comments