From 7652295d2c9675da2b3b5297b115478739aff950 Mon Sep 17 00:00:00 2001 From: ManyTheFish Date: Wed, 1 Jun 2022 15:50:13 +0200 Subject: [PATCH] Encode key in base64 instead of hexa --- Cargo.lock | 1 + meilisearch-auth/Cargo.toml | 1 + meilisearch-auth/src/store.rs | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index f48e6c59d..b72913520 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1973,6 +1973,7 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" name = "meilisearch-auth" version = "0.27.1" dependencies = [ + "base64", "enum-iterator", "meilisearch-error", "milli", diff --git a/meilisearch-auth/Cargo.toml b/meilisearch-auth/Cargo.toml index 7ffa072e8..dafeeef05 100644 --- a/meilisearch-auth/Cargo.toml +++ b/meilisearch-auth/Cargo.toml @@ -11,6 +11,7 @@ rand = "0.8.4" serde = { version = "1.0.136", features = ["derive"] } serde_json = { version = "1.0.79", features = ["preserve_order"] } sha2 = "0.10.2" +base64 = "0.13.0" thiserror = "1.0.30" time = { version = "0.3.7", features = ["serde-well-known", "formatting", "parsing", "macros"] } uuid = { version = "0.8.2", features = ["serde", "v4"] } diff --git a/meilisearch-auth/src/store.rs b/meilisearch-auth/src/store.rs index 762e707bc..64cf49544 100644 --- a/meilisearch-auth/src/store.rs +++ b/meilisearch-auth/src/store.rs @@ -238,7 +238,7 @@ impl<'a> milli::heed::BytesEncode<'a> for KeyIdActionCodec { pub fn generate_key(uid: &[u8], master_key: &[u8]) -> String { let key = [uid, master_key].concat(); let sha = Sha256::digest(&key); - format!("{:x}", sha) + base64::encode_config(sha, base64::URL_SAFE_NO_PAD) } /// Divides one slice into two at an index, returns `None` if mid is out of bounds.