From 7453851092122fc220ef8832d3e9ce90fceabc03 Mon Sep 17 00:00:00 2001 From: Jiale Zhang Date: Fri, 27 Oct 2023 14:16:31 +0800 Subject: [PATCH] Fix: Base64 encode Padding of Policy should be STANDARD Signed-off-by: Jiale Zhang --- attestation-service/src/policy_engine/opa/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/attestation-service/src/policy_engine/opa/mod.rs b/attestation-service/src/policy_engine/opa/mod.rs index adf365a..77597ff 100644 --- a/attestation-service/src/policy_engine/opa/mod.rs +++ b/attestation-service/src/policy_engine/opa/mod.rs @@ -119,7 +119,7 @@ impl PolicyEngine for OPA { bail!("OPA Policy Engine only support .rego policy"); } - let policy_bytes = base64::engine::general_purpose::URL_SAFE_NO_PAD + let policy_bytes = base64::engine::general_purpose::STANDARD .decode(input.policy) .map_err(|e| anyhow!("Base64 decode OPA policy string failed: {:?}", e))?; let mut policy_file_path = PathBuf::from( @@ -192,7 +192,7 @@ default allow = true" let input = SetPolicyInput { r#type: "rego".to_string(), policy_id: "test".to_string(), - policy: base64::engine::general_purpose::URL_SAFE_NO_PAD.encode(policy), + policy: base64::engine::general_purpose::STANDARD.encode(policy), }; assert!(opa.set_policy(input).await.is_ok());