Skip to content

Commit 4d1df50

Browse files
committed
fix timestamp deserialization
set defaults for timestamp objects to prevent empty deserialization issues add debug trait to all responses
1 parent a4779dd commit 4d1df50

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "oidc_agent_rs"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
edition = "2021"
55
license = "MIT OR Apache-2.0"
66
description = "Unix only oidc-agent library for Rust."

src/mytoken.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ impl<'de> Deserialize<'de> for Capability {
134134
}
135135
}
136136

137-
#[derive(Serialize, Deserialize)]
137+
#[derive(Serialize, Deserialize, Debug)]
138138
#[serde(rename_all = "lowercase")]
139139
#[allow(non_camel_case_types)]
140140
pub enum MyTokenType {
@@ -146,11 +146,11 @@ pub enum MyTokenType {
146146
#[derive(Serialize, Deserialize, Debug, Hash, Eq, PartialEq, Clone)]
147147
#[allow(non_snake_case)]
148148
pub struct Restriction {
149-
#[serde(with = "chrono::serde::ts_seconds_option")]
149+
#[serde(default, with = "chrono::serde::ts_seconds_option")]
150150
#[serde(skip_serializing_if = "Option::is_none")]
151151
nbf: Option<DateTime<Utc>>,
152152

153-
#[serde(with = "chrono::serde::ts_seconds_option")]
153+
#[serde(default, with = "chrono::serde::ts_seconds_option")]
154154
#[serde(skip_serializing_if = "Option::is_none")]
155155
exp: Option<DateTime<Utc>>,
156156

src/responses.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl Display for Status {
2323
}
2424
}
2525

26-
#[derive(Serialize, Deserialize, Getters)]
26+
#[derive(Serialize, Deserialize, Getters, Debug)]
2727
pub struct OIDCAgentResponse {
2828
status: Status,
2929
}
@@ -39,15 +39,14 @@ pub struct AccessTokenResponse {
3939

4040
impl Response for AccessTokenResponse {}
4141

42-
#[derive(Serialize, Deserialize, Getters)]
42+
#[derive(Serialize, Deserialize, Getters, Debug)]
4343
pub struct MyTokenResponse {
4444
mytoken: Token,
4545
mytoken_issuer: Url,
4646
oidc_issuer: Url,
4747

48-
#[serde(with = "chrono::serde::ts_seconds")]
49-
expires_at: DateTime<Utc>,
50-
48+
#[serde(default, with = "chrono::serde::ts_seconds_option")]
49+
expires_at: Option<DateTime<Utc>>,
5150
mytoken_type: Option<MyTokenType>,
5251
transfer_code: Option<String>,
5352
expires_in: Option<u64>, //Number of seconds according to the Mytoken documentation

0 commit comments

Comments
 (0)