We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 03b9616 commit f72c7aaCopy full SHA for f72c7aa
src/engine/auth.rs
@@ -30,8 +30,17 @@ impl JwtSecret {
30
/// The provided `secret` must be a valid hexadecimal string of length 64.
31
pub fn from_hex<S: AsRef<str>>(hex: S) -> Result<Self> {
32
let hex: &str = hex.as_ref().trim();
33
+ // Remove the "0x" or "0X" prefix if it exists
34
+ let hex = hex
35
+ .strip_prefix("0x")
36
+ .or_else(|| hex.strip_prefix("0X"))
37
+ .unwrap_or(hex);
38
if hex.len() != JWT_SECRET_LEN {
- Err(eyre::eyre!("Invalid JWT secret key length."))
39
+ Err(eyre::eyre!(
40
+ "Invalid JWT secret key length. Expected {} characters, got {}.",
41
+ JWT_SECRET_LEN,
42
+ hex.len()
43
+ ))
44
} else {
45
let hex_bytes = hex::decode(hex)?;
46
let bytes = hex_bytes.try_into().expect("is expected len");
0 commit comments