Skip to content
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

feat: adds --insecure-unmask-key to config whoami #1043

Merged
merged 1 commit into from
Mar 28, 2022
Merged
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
19 changes: 17 additions & 2 deletions src/command/config/whoami.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use rover_client::operations::config::who_am_i::{self, Actor, ConfigWhoAmIInput}
use serde::Serialize;
use structopt::StructOpt;

use houston::CredentialOrigin;
use houston::{mask_key, CredentialOrigin};

use crate::anyhow;
use crate::command::RoverOutput;
Expand All @@ -19,6 +19,14 @@ pub struct WhoAmI {
#[structopt(long = "profile", default_value = "default")]
#[serde(skip_serializing)]
profile_name: String,

/// Unmask the API key that will be sent to Apollo Studio
///
/// You should think very carefully before using this flag.
///
/// If you are sharing your screen your API key could be compromised
#[structopt(long)]
insecure_unmask_key: bool,
}

impl WhoAmI {
Expand Down Expand Up @@ -72,10 +80,17 @@ impl WhoAmI {

let credential =
config::Profile::get_credential(&self.profile_name, &client_config.config)?;

let maybe_masked_key = if self.insecure_unmask_key {
credential.api_key
} else {
mask_key(&credential.api_key)
};

message.push_str(&format!(
"\n{}: {}",
Green.normal().paint("API Key"),
credential.api_key
&maybe_masked_key
));

eprintln!("{}", message);
Expand Down