Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
chore: small auth devx updates (#733)
Browse files Browse the repository at this point in the history
chore: small authentication updates

Co-authored-by: Rashad Alston <[email protected]>
  • Loading branch information
ra0x3 and Rashad Alston authored Apr 5, 2023
1 parent 39776d4 commit ae2f166
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
# enabled: false

# # Which authentication scheme to use.
# strategy: JWT
# strategy: jwt

# # Secret used if JWT authentication is specified.
# jwt_secret: abcdefghijklmnopqrstuvwxyz1234567890*
Expand Down
2 changes: 1 addition & 1 deletion packages/fuel-indexer-lib/src/config/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ impl Env for AuthenticationConfig {
}

#[derive(Serialize, Deserialize, EnumString, AsRefStr, Clone, Debug, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum AuthenticationStrategy {
#[strum(ascii_case_insensitive)]
JWT,
}

Expand Down
2 changes: 1 addition & 1 deletion packages/fuel-indexer-lib/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ pub struct ApiServerArgs {
pub auth_enabled: bool,

/// Authentication scheme used.
#[clap(long, help = "Authentication scheme used.")]
#[clap(long, help = "Authentication scheme used.", value_parser(["jwt"]))]
pub auth_strategy: Option<String>,

/// Secret used for JWT scheme (if JWT scheme is specified).
Expand Down
16 changes: 10 additions & 6 deletions plugins/forc-index/src/ops/forc_index_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ pub fn init(command: AuthCommand) -> anyhow::Result<()> {
.expect("Failed to deploy indexer.");

if res.status() != StatusCode::OK {
error!(
"\n❌ {} returned a non-200 response code: {:?}",
&target,
res.status()
);
if verbose {
error!(
"\n❌ {} returned a non-200 response code: {:?}",
&target,
res.status()
);
} else {
error!("\n❌ Action failed (Status({}))", res.status());
}
return Ok(());
}

Expand Down Expand Up @@ -105,7 +109,7 @@ pub fn init(command: AuthCommand) -> anyhow::Result<()> {
token
);
} else {
info!("\n✅ Authenticated successfully.");
info!("\n✅ Authenticated successfully.\n\nToken: {}", token);
}
} else {
error!("\n❌ Failed to produce a token.");
Expand Down
12 changes: 8 additions & 4 deletions plugins/forc-index/src/ops/forc_index_deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ pub fn init(command: DeployCommand) -> anyhow::Result<()> {

if verbose {
info!(
"Deploying indexer at {} to {}",
"Deploying indexer at {} to {}.",
manifest_path.display(),
target
);
} else {
info!("Deploying indexer");
info!("Deploying indexer...");
}

let mut headers = HeaderMap::new();
Expand Down Expand Up @@ -109,9 +109,13 @@ pub fn init(command: DeployCommand) -> anyhow::Result<()> {
.expect("Failed to read JSON response.");

if status != StatusCode::OK {
error!("\n❌ {target} returned a non-200 response code: {status:?}",);
if verbose {
error!("\n❌ {target} returned a non-200 response code: {status:?}",);

println!("\n{}", to_string_pretty(&res_json)?);
info!("\n{}", to_string_pretty(&res_json)?);
} else {
info!("\n{}", to_string_pretty(&res_json)?);
}

return Ok(());
}
Expand Down

0 comments on commit ae2f166

Please sign in to comment.