diff --git a/app/src/pages/listShow/PublicTable.vue b/app/src/pages/listShow/PublicTable.vue
index cf7c646061d8327add812d1beb64c9b96342725a..304054ecf1908dbccfc0fad083832498ce9a772a 100644
--- a/app/src/pages/listShow/PublicTable.vue
+++ b/app/src/pages/listShow/PublicTable.vue
@@ -30,6 +30,13 @@
{{ scope.row.fingerprint }}
+
@@ -225,13 +232,13 @@ const copy = () => {
let clipboard = new Clipboard(".tag");
clipboard.on("success", (e) => {
ElMessage({
- message: "复制成功",
+ message: "Successfully copied",
type: "success",
});
clipboard.destroy();
});
clipboard.on("error", (e) => {
- ElMessage.error("复制失败");
+ ElMessage.error("Failed to copy");
clipboard.destroy();
});
};
diff --git a/src/domain/datakey/entity.rs b/src/domain/datakey/entity.rs
index 815c4f95ebe65fd5c172027d51b4502104f832a6..48b8b6d49dee7d62368464327c26a8b58da29abf 100644
--- a/src/domain/datakey/entity.rs
+++ b/src/domain/datakey/entity.rs
@@ -104,7 +104,8 @@ pub struct DataKey {
pub certificate: Vec,
pub create_at: DateTime,
pub expire_at: DateTime,
- pub key_state: KeyState
+ pub key_state: KeyState,
+ pub user_email: Option,
}
impl ExtendableAttributes for DataKey {
diff --git a/src/infra/database/model/datakey/dto.rs b/src/infra/database/model/datakey/dto.rs
index 89674f7504b3b79daaad166c81f21cb3884fa148..a20bbdfbc3250625eb5d100ff50c9c26bbdf55ee 100644
--- a/src/infra/database/model/datakey/dto.rs
+++ b/src/infra/database/model/datakey/dto.rs
@@ -39,7 +39,8 @@ pub(super) struct DataKeyDTO {
pub certificate: String,
pub create_at: DateTime,
pub expire_at: DateTime,
- pub key_state: String
+ pub key_state: String,
+ pub user_email: Option,
}
@@ -62,6 +63,7 @@ impl TryFrom for DataKey {
create_at: dto.create_at,
expire_at: dto.expire_at,
key_state: KeyState::from_str(&dto.key_state)?,
+ user_email: dto.user_email,
})
}
}
@@ -91,6 +93,7 @@ impl TryFrom for DataKeyDTO {
create_at: data_key.create_at,
expire_at: data_key.expire_at,
key_state: data_key.key_state.to_string(),
+ user_email: None
})
}
}
diff --git a/src/infra/database/model/datakey/repository.rs b/src/infra/database/model/datakey/repository.rs
index eda2f722026628ccb4bf05eb2295d155896be2b0..1f42db0b84cd7f8cdd6eefb6ee527cddc0e5763a 100644
--- a/src/infra/database/model/datakey/repository.rs
+++ b/src/infra/database/model/datakey/repository.rs
@@ -83,7 +83,10 @@ impl Repository for DataKeyRepository {
}
async fn get_public_keys(&self) -> Result> {
- let dtos: Vec = sqlx::query_as("SELECT * FROM data_key WHERE key_state != ? and visibility = ?")
+ let dtos: Vec = sqlx::query_as(
+ "SELECT D.*, U.email AS user_email \
+ FROM data_key D INNER JOIN user U ON D.user = U.id \
+ WHERE D.key_state != ? and D.visibility = ?")
.bind(KeyState::Deleted.to_string())
.bind(Visibility::Public.to_string())
.fetch_all(&self.db_pool)
@@ -96,7 +99,10 @@ impl Repository for DataKeyRepository {
}
async fn get_all_keys(&self) -> Result> {
- let dtos: Vec = sqlx::query_as("SELECT * FROM data_key WHERE key_state != ?")
+ let dtos: Vec = sqlx::query_as(
+ "SELECT D.*, U.email AS user_email \
+ FROM data_key D INNER JOIN user U ON D.user = U.id \
+ WHERE D.key_state != ?")
.bind(KeyState::Deleted.to_string())
.fetch_all(&self.db_pool)
.await?;
@@ -107,7 +113,10 @@ impl Repository for DataKeyRepository {
Ok(results)
}
async fn get_private_keys(&self, user_id: i32) -> Result> {
- let dtos: Vec = sqlx::query_as("SELECT * FROM data_key WHERE key_state != ? and visibility = ? and user = ?")
+ let dtos: Vec = sqlx::query_as(
+ "SELECT D.*, U.email AS user_email \
+ FROM data_key D INNER JOIN user U ON D.user = U.id \
+ WHERE D.key_state != ? and D.visibility = ? and D.user = ?")
.bind(KeyState::Deleted.to_string())
.bind(Visibility::Private.to_string())
.bind(user_id)
@@ -121,7 +130,10 @@ impl Repository for DataKeyRepository {
}
async fn get_by_id(&self, id: i32) -> Result {
- let dto: DataKeyDTO = sqlx::query_as("SELECT * FROM data_key WHERE id = ? AND key_state != ?")
+ let dto: DataKeyDTO = sqlx::query_as(
+ "SELECT D.*, U.email AS user_email \
+ FROM data_key D INNER JOIN user U ON D.user = U.id \
+ WHERE D.id = ? AND D.key_state != ?")
.bind(id)
.bind(KeyState::Deleted.to_string())
.fetch_one(&self.db_pool)
@@ -130,7 +142,10 @@ impl Repository for DataKeyRepository {
}
async fn get_by_name(&self, name: &String) -> Result {
- let dto: DataKeyDTO = sqlx::query_as("SELECT * FROM data_key WHERE name = ? AND key_state != ?")
+ let dto: DataKeyDTO = sqlx::query_as(
+ "SELECT D.*, U.email AS user_email \
+ FROM data_key D INNER JOIN user U ON D.user = U.id \
+ WHERE D.name = ? AND D.key_state != ?")
.bind(name)
.bind(KeyState::Deleted.to_string())
.fetch_one(&self.db_pool)
@@ -150,7 +165,10 @@ impl Repository for DataKeyRepository {
}
async fn get_enabled_key_by_type_and_name(&self, key_type: String, name: String) -> Result {
- let dto: DataKeyDTO = sqlx::query_as("SELECT * FROM data_key WHERE name = ? AND key_type = ? AND key_state = ?")
+ let dto: DataKeyDTO = sqlx::query_as(
+ "SELECT D.*, U.email AS user_email \
+ FROM data_key D INNER JOIN user U ON D.user = U.id \
+ WHERE D.name = ? AND D.key_type = ? AND D.key_state = ?")
.bind(name)
.bind(key_type)
.bind(KeyState::Enabled.to_string())
diff --git a/src/infra/encryption/engine.rs b/src/infra/encryption/engine.rs
index af3d692bcef8e8b7e40be3a2c2b5cd26c230a976..4eb603d38f2b83c53daf4ebdfbee31c676bbd75c 100644
--- a/src/infra/encryption/engine.rs
+++ b/src/infra/encryption/engine.rs
@@ -73,6 +73,7 @@ where
if rotate_in_days < DEFAULT_ROTATE_IN_DAYS {
return Err(Error::ConfigError(format!("rotate in days should greater than {}", rotate_in_days)));
}
+ info!("cluster key will be rotated in {} days", rotate_in_days);
Ok(EncryptionEngineWithClusterKey {
cluster_repository,
encryptor,
diff --git a/src/infra/sign_plugin/openpgp.rs b/src/infra/sign_plugin/openpgp.rs
index 26bd88dfdb3650606d9ae358062f8172b5afe4a1..6ba0975112db25015d8adf6cfa0c2100ace1e3e0 100644
--- a/src/infra/sign_plugin/openpgp.rs
+++ b/src/infra/sign_plugin/openpgp.rs
@@ -39,9 +39,9 @@ use crate::domain::datakey::entity::{DataKey, DataKeyContent, SecDataKey, KeyTyp
use crate::util::key::encode_u8_to_hex_string;
use super::util::{validate_utc_time_not_expire, validate_utc_time, attributes_validate};
-const VALID_KEY_TYPE: [&'static str; 2] = ["rsa", "eddsa"];
-const VALID_KEY_SIZE: [&'static str; 3] = ["2048", "3072", "4096"];
-const VALID_DIGEST_ALGORITHM: [&'static str; 10] = ["none", "md5", "sha1", "sha1", "sha2_256", "sha2_384","sha2_512","sha2_224","sha3_256", "sha3_512"];
+const VALID_KEY_TYPE: [&str; 2] = ["rsa", "eddsa"];
+const VALID_KEY_SIZE: [&str; 3] = ["2048", "3072", "4096"];
+const VALID_DIGEST_ALGORITHM: [&str; 10] = ["none", "md5", "sha1", "sha1", "sha2_256", "sha2_384","sha2_512","sha2_224","sha3_256", "sha3_512"];
#[derive(Debug, Validate, Deserialize)]
pub struct PgpKeyImportParameter {
diff --git a/src/infra/sign_plugin/x509.rs b/src/infra/sign_plugin/x509.rs
index 3eab3ab47e07656a2248faed21ea92c25299c9c5..d7748db7e96e9ea22d6ba7635d44aead5236c6b2 100644
--- a/src/infra/sign_plugin/x509.rs
+++ b/src/infra/sign_plugin/x509.rs
@@ -40,9 +40,9 @@ use crate::domain::sign_plugin::SignPlugins;
use crate::util::key::encode_u8_to_hex_string;
use super::util::{validate_utc_time_not_expire, validate_utc_time, attributes_validate};
-const VALID_KEY_TYPE: [&'static str; 2] = ["rsa", "dsa"];
-const VALID_KEY_SIZE: [&'static str; 3] = ["2048", "3072", "4096"];
-const VALID_DIGEST_ALGORITHM: [&'static str; 6] = ["md5", "sha1", "sha2_256","sha2_384","sha2_512","sha2_224"];
+const VALID_KEY_TYPE: [&str; 2] = ["rsa", "dsa"];
+const VALID_KEY_SIZE: [&str; 3] = ["2048", "3072", "4096"];
+const VALID_DIGEST_ALGORITHM: [&str; 6] = ["md5", "sha1", "sha2_256","sha2_384","sha2_512","sha2_224"];
#[derive(Debug, Validate, Deserialize)]
pub struct X509KeyGenerationParameter {
diff --git a/src/presentation/handler/control/model/datakey/dto.rs b/src/presentation/handler/control/model/datakey/dto.rs
index 37429d392c53b4375c9efc0b201a92e5e5865bfd..070f5f3059ed20c0122db4264ec3643bd7286c12 100644
--- a/src/presentation/handler/control/model/datakey/dto.rs
+++ b/src/presentation/handler/control/model/datakey/dto.rs
@@ -131,6 +131,8 @@ pub struct DataKeyDTO {
pub expire_at: String,
/// Key state
pub key_state: String,
+ /// User email
+ pub user_email: Option,
}
fn validate_utc_time(expire: &str) -> std::result::Result<(), ValidationError> {
@@ -194,7 +196,8 @@ impl DataKey {
certificate: dto.certificate.into_bytes(),
create_at: now,
expire_at: now,
- key_state: KeyState::default()
+ key_state: KeyState::default(),
+ user_email: None,
})
}
@@ -223,7 +226,8 @@ impl DataKey {
certificate: vec![],
create_at: now,
expire_at: dto.expire_at.parse()?,
- key_state: KeyState::default()
+ key_state: KeyState::default(),
+ user_email: None,
})
}
}
@@ -246,6 +250,7 @@ impl TryFrom for DataKeyDTO {
create_at: dto.create_at.to_string(),
expire_at: dto.expire_at.to_string(),
key_state: dto.key_state.to_string(),
+ user_email: dto.user_email,
})
}
}