aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConrad Ludgate <conradludgate@gmail.com>2023-08-02 22:46:07 +0100
committerGitHub <noreply@github.com>2023-08-02 21:46:07 +0000
commitaf14366a2edb976d21977bc1fc7b4203d2fbae6f (patch)
tree6d2c4a00904d71162146f0876a77ba6df6f172ac
parentBump futures-util from 0.3.24 to 0.3.28 (#1129) (diff)
downloadatuin-af14366a2edb976d21977bc1fc7b4203d2fbae6f.zip
encode paseto payloads as json (#1146)
-rw-r--r--atuin-client/src/record/encryption.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/atuin-client/src/record/encryption.rs b/atuin-client/src/record/encryption.rs
index 6760d97b..3074a9c2 100644
--- a/atuin-client/src/record/encryption.rs
+++ b/atuin-client/src/record/encryption.rs
@@ -72,7 +72,10 @@ impl Encryption for PASETO_V4 {
let assertions = Assertions::from(ad).encode();
// build the payload and encrypt the token
- let payload = general_purpose::URL_SAFE_NO_PAD.encode(data.0);
+ let payload = serde_json::to_string(&AtuinPayload {
+ data: general_purpose::URL_SAFE_NO_PAD.encode(data.0),
+ })
+ .expect("json encoding can't fail");
let nonce = DataKey::<32>::try_new_random().expect("could not source from random");
let nonce = PasetoNonce::<V4, LocalPurpose>::from(&nonce);
@@ -104,7 +107,8 @@ impl Encryption for PASETO_V4 {
)
.context("could not decrypt entry")?;
- let data = general_purpose::URL_SAFE_NO_PAD.decode(payload)?;
+ let payload: AtuinPayload = serde_json::from_str(&payload)?;
+ let data = general_purpose::URL_SAFE_NO_PAD.decode(payload.data)?;
Ok(DecryptedData(data))
}
}
@@ -147,6 +151,11 @@ impl PASETO_V4 {
}
#[derive(Serialize, Deserialize)]
+struct AtuinPayload {
+ data: String,
+}
+
+#[derive(Serialize, Deserialize)]
/// Well-known footer claims for decrypting. This is not encrypted but is stored in the record.
/// <https://github.com/paseto-standard/paseto-spec/blob/master/docs/02-Implementation-Guide/04-Claims.md#optional-footer-claims>
struct AtuinFooter {