@@ -20,7 +20,6 @@ use std::collections::HashMap;
2020
2121use chrono:: { DateTime , Utc } ;
2222use once_cell:: sync:: Lazy ;
23- use rand:: Rng ;
2423use serde:: { Deserialize , Serialize } ;
2524use tokio:: sync:: RwLock ;
2625use ulid:: Ulid ;
@@ -77,7 +76,7 @@ impl ApiKey {
7776 let now = Utc :: now ( ) ;
7877 Self {
7978 key_id : Ulid :: new ( ) ,
80- api_key : generate_uuid_v4 ( ) ,
79+ api_key : uuid :: Uuid :: new_v4 ( ) . to_string ( ) ,
8180 key_name,
8281 created_by,
8382 created_at : now,
@@ -114,25 +113,6 @@ impl MetastoreObject for ApiKey {
114113 }
115114}
116115
117- /// Generate a UUID v4 formatted string using rand
118- fn generate_uuid_v4 ( ) -> String {
119- let mut rng = rand:: thread_rng ( ) ;
120- let mut bytes = [ 0u8 ; 16 ] ;
121- rng. fill ( & mut bytes) ;
122- // Set version 4 (bits 12-15 of time_hi_and_version)
123- bytes[ 6 ] = ( bytes[ 6 ] & 0x0f ) | 0x40 ;
124- // Set variant 1 (bits 6-7 of clock_seq_hi_and_reserved)
125- bytes[ 8 ] = ( bytes[ 8 ] & 0x3f ) | 0x80 ;
126- format ! (
127- "{:02x}{:02x}{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}" ,
128- bytes[ 0 ] , bytes[ 1 ] , bytes[ 2 ] , bytes[ 3 ] ,
129- bytes[ 4 ] , bytes[ 5 ] ,
130- bytes[ 6 ] , bytes[ 7 ] ,
131- bytes[ 8 ] , bytes[ 9 ] ,
132- bytes[ 10 ] , bytes[ 11 ] , bytes[ 12 ] , bytes[ 13 ] , bytes[ 14 ] , bytes[ 15 ]
133- )
134- }
135-
136116impl ApiKeyStore {
137117 /// Load API keys from object store into memory
138118 pub async fn load ( & self ) -> anyhow:: Result < ( ) > {
0 commit comments