Skip to content

Commit 2b9d99c

Browse files
authored
Merge pull request #127 from wa5i/bugfix
Fix bug causing authentication failure due to missing fields when using old tokens
2 parents 8bedbcf + 1b2a77e commit 2b9d99c

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/modules/auth/token_store.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use crate::{
3636
storage::{Storage, StorageEntry},
3737
utils::{
3838
deserialize_duration, deserialize_system_time, generate_uuid, is_str_subset,
39-
policy::sanitize_policies,
39+
default_system_time, policy::sanitize_policies,
4040
serialize_duration, serialize_system_time, sha1,
4141
token_util::{DEFAULT_LEASE_TTL, MAX_LEASE_TTL},
4242
},
@@ -94,11 +94,11 @@ pub struct TokenEntry {
9494
pub num_uses: u32,
9595
pub ttl: u64,
9696
#[default(SystemTime::now())]
97-
#[serde(serialize_with = "serialize_system_time", deserialize_with = "deserialize_system_time")]
97+
#[serde(default = "default_system_time", serialize_with = "serialize_system_time", deserialize_with = "deserialize_system_time")]
9898
pub creation_time: SystemTime,
99-
#[serde(serialize_with = "serialize_duration", deserialize_with = "deserialize_duration")]
99+
#[serde(default, serialize_with = "serialize_duration", deserialize_with = "deserialize_duration")]
100100
pub period: Duration,
101-
#[serde(serialize_with = "serialize_duration", deserialize_with = "deserialize_duration")]
101+
#[serde(default, serialize_with = "serialize_duration", deserialize_with = "deserialize_duration")]
102102
pub explicit_max_ttl: Duration,
103103
}
104104

src/modules/pki/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ x/+V28hUf8m8P2NxP5ALaDZagdaMfzjGZo3O3wDv33Cds0P5GMGQYnRXDxcZN/2L
598598
#[cfg(feature = "crypto_adaptor_tongsuo")]
599599
#[maybe_async::test(feature = "sync_handler", async(all(not(feature = "sync_handler")), tokio::test))]
600600
async fn test_pki_sm2_generate_root() {
601-
let (root_token, c) = test_rusty_vault_init("test_pki_generate_root");
601+
let (root_token, c) = test_rusty_vault_init("test_pki_sm2_generate_root");
602602
let token = &root_token;
603603
let core = c.read().unwrap();
604604
let path = "sm2pki/";

src/utils/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,7 @@ pub fn is_protect_path(protected: &[&str], paths: &[&str]) -> bool {
152152

153153
false
154154
}
155+
156+
pub fn default_system_time() -> SystemTime {
157+
SystemTime::UNIX_EPOCH
158+
}

0 commit comments

Comments
 (0)