fix(token): update token generation to use rand::rng() to resolve deprecation warnings

This commit is contained in:
Mike Boensel 2026-02-18 02:11:51 -05:00
parent 42bf05df47
commit 0166f2d4de

View file

@ -176,14 +176,14 @@ fn generate_code() -> String {
/// Generate a cryptographically-adequate bearer token with 256-bit entropy. /// Generate a cryptographically-adequate bearer token with 256-bit entropy.
/// ///
/// Uses `rand::thread_rng()` which is backed by the OS CSPRNG /// Uses `rand::rng()` which is backed by the OS CSPRNG
/// (/dev/urandom on Linux, BCryptGenRandom on Windows, SecRandomCopyBytes /// (/dev/urandom on Linux, BCryptGenRandom on Windows, SecRandomCopyBytes
/// on macOS). The 32 random bytes (256 bits) are hex-encoded for a /// on macOS). The 32 random bytes (256 bits) are hex-encoded for a
/// 64-character token, providing 256 bits of entropy. /// 64-character token, providing 256 bits of entropy.
fn generate_token() -> String { fn generate_token() -> String {
use rand::RngCore; use rand::RngCore;
let mut bytes = [0u8; 32]; let mut bytes = [0u8; 32];
rand::thread_rng().fill_bytes(&mut bytes); rand::rng().fill_bytes(&mut bytes);
format!("zc_{}", hex::encode(bytes)) format!("zc_{}", hex::encode(bytes))
} }