fix(cli): expose an encrypt value endpoint

This commit is contained in:
Ruben Fiszel
2023-05-27 14:31:23 +02:00
parent 552ed9459c
commit 944ef2df69
3 changed files with 40 additions and 1 deletions
+23
View File
@@ -1181,6 +1181,29 @@ paths:
schema:
type: string
/w/{workspace}/variables/encrypt:
post:
summary: encrypt value
operationId: encryptValue
tags:
- variable
parameters:
- $ref: "#/components/parameters/WorkspaceId"
requestBody:
description: new variable
required: true
content:
application/json:
schema:
type: string
responses:
"200":
description: encrypted value
content:
text/plain:
schema:
type: string
/w/{workspace}/variables/delete/{path}:
delete:
summary: delete variable
+16
View File
@@ -40,6 +40,7 @@ pub fn workspaced_service() -> Router {
.route("/update/*path", post(update_variable))
.route("/delete/*path", delete(delete_variable))
.route("/create", post(create_variable))
.route("/encrypt", post(encrypt_value))
}
async fn list_contextual_variables(
@@ -257,6 +258,21 @@ async fn create_variable(
))
}
async fn encrypt_value(
Extension(db): Extension<DB>,
Path(w_id): Path<String>,
Json(variable): Json<String>,
) -> Result<String> {
let mut tx = db.begin().await?;
let mc = build_crypt(&mut tx, &w_id).await?;
let value = encrypt(&mc, &variable);
tx.commit().await?;
Ok(value)
}
async fn delete_variable(
authed: Authed,
Extension(user_db): Extension<UserDB>,
+1 -1
View File
@@ -81,7 +81,7 @@ async function pull(opts: GlobalOptions) {
x.name + ".resource-type.json",
undefined,
x,
false
true
);
}
}