WIP
This commit is contained in:
parent
2c5919a972
commit
b04461c885
3 changed files with 24 additions and 12 deletions
|
|
@ -144,8 +144,8 @@ pub async fn post_data(
|
||||||
engine_path,
|
engine_path,
|
||||||
nonce: todo!(),
|
nonce: todo!(),
|
||||||
encrypted_data: todo!(),
|
encrypted_data: todo!(),
|
||||||
}
|
};
|
||||||
let signature = secret_content.sign().await;
|
let signature = secret_version.sign().await.to_vec();
|
||||||
let res_r = sqlx::query_file!(
|
let res_r = sqlx::query_file!(
|
||||||
"src/engines/kv/post_secret.sql",
|
"src/engines/kv/post_secret.sql",
|
||||||
engine_path,
|
engine_path,
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
|
|
||||||
WITH latest_version AS (
|
WITH latest_version AS (
|
||||||
SELECT MAX(version_number) AS max_version
|
SELECT MAX(version_number) AS max_version, signature
|
||||||
FROM kv2_secret_version
|
FROM kv2_secret_version
|
||||||
WHERE engine_path = $1 AND secret_path = $2 -- engine_path AND secret_path
|
WHERE engine_path = $1 AND secret_path = $2 -- engine_path AND secret_path
|
||||||
)
|
)
|
||||||
INSERT INTO kv2_secret_version (engine_path, secret_path, nonce, encrypted_data, created_time, version_number)
|
INSERT INTO kv2_secret_version (engine_path, secret_path, nonce, encrypted_data, created_time, version_number, signature)
|
||||||
VALUES (
|
VALUES (
|
||||||
$1, -- engine_path
|
$1, -- engine_path
|
||||||
$2, -- secret_path
|
$2, -- secret_path
|
||||||
|
|
@ -14,6 +14,7 @@ VALUES (
|
||||||
CASE -- Use provided version if given
|
CASE -- Use provided version if given
|
||||||
WHEN $6 IS NOT NULL THEN $6 -- version_number (optional)
|
WHEN $6 IS NOT NULL THEN $6 -- version_number (optional)
|
||||||
ELSE COALESCE((SELECT max_version FROM latest_version) + 1, 1) -- otherwise 1
|
ELSE COALESCE((SELECT max_version FROM latest_version) + 1, 1) -- otherwise 1
|
||||||
END -- version_number logic
|
END, -- version_number logic
|
||||||
|
$7 -- signature
|
||||||
)
|
)
|
||||||
RETURNING version_number;
|
RETURNING version_number, signature;
|
||||||
|
|
|
||||||
|
|
@ -33,10 +33,11 @@ pub fn signed_dbo(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||||
for field in fields {
|
for field in fields {
|
||||||
new_fields.extend(quote! { #field, });
|
new_fields.extend(quote! { #field, });
|
||||||
}
|
}
|
||||||
|
// expand_input
|
||||||
let a = sqlx::query_unchecked!(r"SELECT name
|
// let a = sqlx::query(r"SELECT name
|
||||||
FROM pragma_table_info('kv2_metadata')
|
// FROM pragma_table_info('kv2_metadata')
|
||||||
WHERE pk > 0");
|
// WHERE pk > 0").fetch_one(&input.);
|
||||||
|
// print!("aaa {a}");
|
||||||
|
|
||||||
let expanded = quote! {
|
let expanded = quote! {
|
||||||
#[derive(serde::Serialize)]
|
#[derive(serde::Serialize)]
|
||||||
|
|
@ -58,9 +59,19 @@ WHERE pk > 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
impl #struct_name {
|
impl #struct_name {
|
||||||
async fn fetch_one()
|
async fn fetch_one() {
|
||||||
}
|
// sqlx::query_as!(#struct_name, r"
|
||||||
|
// SELECT * FROM $1 WHERE engine_path = $2, path = $3
|
||||||
|
// ")
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn insert_one(&mut self) {
|
||||||
|
// self.signature = await self.sign();
|
||||||
|
// sqlx::query!(r"
|
||||||
|
// INSERT INTO $1
|
||||||
|
// ")
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TokenStream::from(expanded)
|
TokenStream::from(expanded)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue