Skip to content

fix(pyth-lazer-agent) Stop logging the access_token #2882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/pyth-lazer-agent/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyth-lazer-agent"
version = "0.3.1"
version = "0.3.2"
edition = "2024"

[dependencies]
Expand Down
23 changes: 18 additions & 5 deletions apps/pyth-lazer-agent/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
use std::net::SocketAddr;
use std::path::PathBuf;
use std::time::Duration;

use config::{Environment, File};
use derivative::Derivative;
use serde::Deserialize;
use std::cmp::min;
use std::fmt::{Debug, Formatter};
use std::net::SocketAddr;
use std::path::PathBuf;
use std::time::Duration;
use url::Url;

#[derive(Deserialize, Derivative, Clone, PartialEq)]
#[derivative(Debug)]
pub struct Config {
pub listen_address: SocketAddr,
pub relayer_urls: Vec<Url>,
pub authorization_token: Option<String>,
pub authorization_token: Option<AuthorizationToken>,
#[derivative(Debug = "ignore")]
pub publish_keypair_path: PathBuf,
#[serde(with = "humantime_serde", default = "default_publish_interval")]
pub publish_interval_duration: Duration,
pub history_service_url: Option<Url>,
}

#[derive(Deserialize, Derivative, Clone, PartialEq)]
pub struct AuthorizationToken(pub String);

impl Debug for AuthorizationToken {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let token_string = self.0.to_ascii_lowercase();
#[allow(clippy::string_slice, reason = "false positive")]
let last_chars = &token_string[token_string.len() - min(4, token_string.len())..];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't it panic if the string is empty?

write!(f, "\"...{last_chars}\"")
}
}

fn default_publish_interval() -> Duration {
Duration::from_micros(500)
}
Expand Down
2 changes: 1 addition & 1 deletion apps/pyth-lazer-agent/src/lazer_publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl LazerPublisher {
let authorization_token =
if let Some(authorization_token) = config.authorization_token.clone() {
// If authorization_token is configured, use it.
authorization_token
authorization_token.0
} else {
// Otherwise, use the base64 pubkey.
BASE64_STANDARD.encode(signing_key.verifying_key().to_bytes())
Expand Down