Skip to content

Commit

Permalink
use SecretString for auth fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Quinn committed Dec 29, 2024
1 parent 67ed8d7 commit 748ac03
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 18 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion relay-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ clap = { version = "4", features = ["derive"] }
eyre.workspace = true
orb-relay-messages.workspace = true
orb-security-utils = { workspace = true, features = ["reqwest"] }
orb-telemetry.workspace = true
rand = "0.8"
serde_json.workspace = true
secrecy.workspace = true
sha2 = "0.10"
tokio-stream.workspace = true
tokio-util.workspace = true
tokio.workspace = true
tracing-subscriber = "0.3"
tracing-subscriber.workspace = true
tracing.workspace = true
4 changes: 3 additions & 1 deletion relay-client/src/bin/manual-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ struct Args {

#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt().init();
orb_telemetry::TelemetryConfig::new()
.with_journald("worldcoin-relay-client")
.init();

let args = Args::parse();

Expand Down
39 changes: 23 additions & 16 deletions relay-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use orb_security_utils::reqwest::{
GTS_ROOT_R1_CERT, GTS_ROOT_R2_CERT, GTS_ROOT_R3_CERT, GTS_ROOT_R4_CERT,
SFS_ROOT_G2_CERT,
};
use secrecy::{ExposeSecret, SecretString};
use std::{
any::type_name,
collections::{BTreeMap, VecDeque},
Expand All @@ -38,15 +39,15 @@ use tokio_util::sync::CancellationToken;

#[derive(Debug, Clone)]
pub struct TokenAuth {
token: String,
token: SecretString,
}

#[derive(Debug, Clone)]
pub struct ZkpAuth {
root: String,
signal: String,
nullifier_hash: String,
proof: String,
root: SecretString,
signal: SecretString,
nullifier_hash: SecretString,
proof: SecretString,
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -164,7 +165,9 @@ impl Client {
) -> Self {
Self::new(
url,
Auth::Token(TokenAuth { token }),
Auth::Token(TokenAuth {
token: token.into(),
}),
orb_id,
session_id,
Mode::Orb,
Expand All @@ -181,7 +184,9 @@ impl Client {
) -> Self {
Self::new(
url,
Auth::Token(TokenAuth { token }),
Auth::Token(TokenAuth {
token: token.into(),
}),
session_id,
orb_id,
Mode::App,
Expand All @@ -202,10 +207,10 @@ impl Client {
Self::new(
url,
Auth::ZKP(ZkpAuth {
root,
signal,
nullifier_hash,
proof,
root: root.into(),
signal: signal.into(),
nullifier_hash: nullifier_hash.into(),
proof: proof.into(),
}),
session_id,
orb_id,
Expand Down Expand Up @@ -694,12 +699,14 @@ impl<'a> PollerAgent<'a> {
},
}),
auth_method: Some(match &self.config.auth {
Auth::Token(t) => AuthMethod::Token(t.token.clone()),
Auth::Token(t) => {
AuthMethod::Token(t.token.expose_secret().to_string())
}
Auth::ZKP(z) => AuthMethod::ZkpAuthRequest(ZkpAuthRequest {
root: z.root.clone(),
signal: z.signal.clone(),
nullifier_hash: z.nullifier_hash.clone(),
proof: z.proof.clone(),
root: z.root.expose_secret().to_string(),
signal: z.signal.expose_secret().to_string(),
nullifier_hash: z.nullifier_hash.expose_secret().to_string(),
proof: z.proof.expose_secret().to_string(),
}),
}),
})),
Expand Down

0 comments on commit 748ac03

Please sign in to comment.