From 7ded17f45b42b803ccc16c766a8880ca8fadccaa Mon Sep 17 00:00:00 2001 From: Phuong Nguyen Date: Tue, 5 Sep 2023 13:38:50 +0200 Subject: [PATCH] Try diff terraform type --- infra/modules/leader/variables.tf | 1 + infra/terraform-dev.tfvars | 2 +- mpc-recovery/src/main.rs | 18 +++--------------- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/infra/modules/leader/variables.tf b/infra/modules/leader/variables.tf index 0975181f0..7c6606eb2 100644 --- a/infra/modules/leader/variables.tf +++ b/infra/modules/leader/variables.tf @@ -37,6 +37,7 @@ variable "account_creator_id" { } variable "allowed_oidc_providers" { + type = list(map(string)) } # Secrets diff --git a/infra/terraform-dev.tfvars b/infra/terraform-dev.tfvars index 7da938c30..fd1fb5d56 100644 --- a/infra/terraform-dev.tfvars +++ b/infra/terraform-dev.tfvars @@ -10,5 +10,5 @@ sk_shares = [ "{\"public_key\":{\"curve\":\"ed25519\",\"point\":[226,221,12,58,210,76,171,11,139,88,242,44,18,207,126,120,5,90,208,108,4,93,19,188,24,172,130,61,51,94,10,34]},\"expanded_private_key\":{\"prefix\":{\"curve\":\"ed25519\",\"scalar\":[72,32,251,204,100,91,164,82,140,231,84,166,176,30,167,99,107,71,71,195,83,40,241,205,6,89,122,227,140,146,82,4]},\"private_key\":{\"curve\":\"ed25519\",\"scalar\":[8,248,184,114,40,88,141,189,156,115,215,171,36,210,85,189,12,217,176,9,208,28,141,207,18,18,57,230,231,14,118,116]}}}" ] allowed_oidc_providers = [ - "{\"issuer\":\"https://securetoken.google.com/pagoda-oboarding-dev\",\"audience\":\"pagoda-oboarding-dev\"}" + { issuer = "https://securetoken.google.com/pagoda-oboarding-dev", audience = "pagoda-oboarding-dev" } ] \ No newline at end of file diff --git a/mpc-recovery/src/main.rs b/mpc-recovery/src/main.rs index 72e5d8390..f4ce41316 100644 --- a/mpc-recovery/src/main.rs +++ b/mpc-recovery/src/main.rs @@ -1,4 +1,4 @@ -use std::path::PathBuf; +use std::{collections::HashSet, path::PathBuf}; use aes_gcm::{ aead::{consts::U32, generic_array::GenericArray, KeyInit}, @@ -196,11 +196,11 @@ async fn load_oidc_providers( format!("mpc-recovery-allowed-oidc-providers-{node_id}-{env}/versions/latest"); let x = std::str::from_utf8(&gcp_service.load_secret(name).await?)?.to_string(); tracing::info!("Loaded OIDC providers: {x:?}"); - let oidc_providers: Vec = + let oidc_providers: HashSet = serde_json::from_str(&x)?; Ok(AllowedOidcProviders { - entries: oidc_providers.into_iter().collect(), + entries: oidc_providers, }) } } @@ -377,15 +377,3 @@ async fn main() -> anyhow::Result<()> { Ok(()) } - -#[cfg(test)] -mod test { - use mpc_recovery::firewall::allowed::OidcProvider; - - #[test] - fn test_() { - let x = "{\"issuer\":\"https://securetoken.google.com/pagoda-oboarding-dev\",\"audience\":\"pagoda-oboarding-dev\"}"; - let y: OidcProvider = serde_json::from_str(&format!("\"{}\"", x)).unwrap(); - println!("{:?}", y); - } -}