Skip to content

Commit 5def9c3

Browse files
authored
fix(pyth-lazer-agent) Stop logging the access_token (#2882)
1 parent e210500 commit 5def9c3

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/pyth-lazer-agent/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pyth-lazer-agent"
3-
version = "0.3.1"
3+
version = "0.3.2"
44
edition = "2024"
55

66
[dependencies]

apps/pyth-lazer-agent/src/config.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,38 @@
1-
use std::net::SocketAddr;
2-
use std::path::PathBuf;
3-
use std::time::Duration;
4-
51
use config::{Environment, File};
62
use derivative::Derivative;
73
use serde::Deserialize;
4+
use std::cmp::min;
5+
use std::fmt::{Debug, Formatter};
6+
use std::net::SocketAddr;
7+
use std::path::PathBuf;
8+
use std::time::Duration;
89
use url::Url;
910

1011
#[derive(Deserialize, Derivative, Clone, PartialEq)]
1112
#[derivative(Debug)]
1213
pub struct Config {
1314
pub listen_address: SocketAddr,
1415
pub relayer_urls: Vec<Url>,
15-
pub authorization_token: Option<String>,
16+
pub authorization_token: Option<AuthorizationToken>,
1617
#[derivative(Debug = "ignore")]
1718
pub publish_keypair_path: PathBuf,
1819
#[serde(with = "humantime_serde", default = "default_publish_interval")]
1920
pub publish_interval_duration: Duration,
2021
pub history_service_url: Option<Url>,
2122
}
2223

24+
#[derive(Deserialize, Derivative, Clone, PartialEq)]
25+
pub struct AuthorizationToken(pub String);
26+
27+
impl Debug for AuthorizationToken {
28+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
29+
let token_string = self.0.to_ascii_lowercase();
30+
#[allow(clippy::string_slice, reason = "false positive")]
31+
let last_chars = &token_string[token_string.len() - min(4, token_string.len())..];
32+
write!(f, "\"...{last_chars}\"")
33+
}
34+
}
35+
2336
fn default_publish_interval() -> Duration {
2437
Duration::from_micros(500)
2538
}

apps/pyth-lazer-agent/src/lazer_publisher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl LazerPublisher {
6262
let authorization_token =
6363
if let Some(authorization_token) = config.authorization_token.clone() {
6464
// If authorization_token is configured, use it.
65-
authorization_token
65+
authorization_token.0
6666
} else {
6767
// Otherwise, use the base64 pubkey.
6868
BASE64_STANDARD.encode(signing_key.verifying_key().to_bytes())

0 commit comments

Comments
 (0)