Skip to content

Commit

Permalink
cdh/storage: allow plaintext for mount metadata
Browse files Browse the repository at this point in the history
Before this commit, the mount metadata of alibaba cloud oss must be a
sealed secret. In some scenarios, confidential data hub is not used in
kubernetes but CVM.

We should allow the users to directly configure the metadata with
plaintext.

Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
  • Loading branch information
Xynnn007 committed Jan 24, 2024
1 parent f1b9088 commit 2ac098f
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use std::os::unix::fs::PermissionsExt;

use base64::{engine::general_purpose::STANDARD, Engine};
use log::debug;
use secret::secret::Secret;
use serde::{Deserialize, Serialize};
use tokio::{fs, io::AsyncWriteExt, process::Command};
Expand Down Expand Up @@ -77,19 +78,19 @@ async fn unseal_secret(secret: Vec<u8>) -> Result<Vec<u8>> {

async fn get_plaintext_secret(secret: &str) -> Result<String> {
if secret.starts_with("sealed.") {
debug!("detected sealed secret");
let tmp = secret
.strip_prefix("sealed.")
.ok_or(Error::SecureMountFailed(
"strip_prefix \"sealed.\" failed".to_string(),
))?;
let unsealed = unseal_secret(tmp.into()).await?;

return String::from_utf8(unsealed)
.map_err(|e| Error::SecureMountFailed(format!("convert to String failed: {e}")));
String::from_utf8(unsealed)
.map_err(|e| Error::SecureMountFailed(format!("convert to String failed: {e}")))
} else {
Ok(secret.into())
}
Err(Error::SecureMountFailed(
"sealed secret format error!".to_string(),
))
}

impl Oss {
Expand Down

0 comments on commit 2ac098f

Please sign in to comment.