From 4d1df506a45f599e32b7004eebbb2106d77a02cb Mon Sep 17 00:00:00 2001 From: Nithe14 Date: Tue, 9 Jul 2024 08:54:21 +0200 Subject: [PATCH] fix timestamp deserialization set defaults for timestamp objects to prevent empty deserialization issues add debug trait to all responses --- Cargo.toml | 2 +- src/mytoken.rs | 6 +++--- src/responses.rs | 9 ++++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a5026f9..34be5f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oidc_agent_rs" -version = "0.1.0" +version = "0.1.1" edition = "2021" license = "MIT OR Apache-2.0" description = "Unix only oidc-agent library for Rust." diff --git a/src/mytoken.rs b/src/mytoken.rs index b04025c..19c8575 100644 --- a/src/mytoken.rs +++ b/src/mytoken.rs @@ -134,7 +134,7 @@ impl<'de> Deserialize<'de> for Capability { } } -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug)] #[serde(rename_all = "lowercase")] #[allow(non_camel_case_types)] pub enum MyTokenType { @@ -146,11 +146,11 @@ pub enum MyTokenType { #[derive(Serialize, Deserialize, Debug, Hash, Eq, PartialEq, Clone)] #[allow(non_snake_case)] pub struct Restriction { - #[serde(with = "chrono::serde::ts_seconds_option")] + #[serde(default, with = "chrono::serde::ts_seconds_option")] #[serde(skip_serializing_if = "Option::is_none")] nbf: Option>, - #[serde(with = "chrono::serde::ts_seconds_option")] + #[serde(default, with = "chrono::serde::ts_seconds_option")] #[serde(skip_serializing_if = "Option::is_none")] exp: Option>, diff --git a/src/responses.rs b/src/responses.rs index a0a7197..bc14616 100644 --- a/src/responses.rs +++ b/src/responses.rs @@ -23,7 +23,7 @@ impl Display for Status { } } -#[derive(Serialize, Deserialize, Getters)] +#[derive(Serialize, Deserialize, Getters, Debug)] pub struct OIDCAgentResponse { status: Status, } @@ -39,15 +39,14 @@ pub struct AccessTokenResponse { impl Response for AccessTokenResponse {} -#[derive(Serialize, Deserialize, Getters)] +#[derive(Serialize, Deserialize, Getters, Debug)] pub struct MyTokenResponse { mytoken: Token, mytoken_issuer: Url, oidc_issuer: Url, - #[serde(with = "chrono::serde::ts_seconds")] - expires_at: DateTime, - + #[serde(default, with = "chrono::serde::ts_seconds_option")] + expires_at: Option>, mytoken_type: Option, transfer_code: Option, expires_in: Option, //Number of seconds according to the Mytoken documentation