Skip to content

Commit

Permalink
fix timestamp deserialization
Browse files Browse the repository at this point in the history
set defaults for timestamp objects to prevent empty deserialization issues
add debug trait to all responses
  • Loading branch information
Nithe14 committed Jul 9, 2024
1 parent a4779dd commit 4d1df50
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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."
Expand Down
6 changes: 3 additions & 3 deletions src/mytoken.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<DateTime<Utc>>,

#[serde(with = "chrono::serde::ts_seconds_option")]
#[serde(default, with = "chrono::serde::ts_seconds_option")]
#[serde(skip_serializing_if = "Option::is_none")]
exp: Option<DateTime<Utc>>,

Expand Down
9 changes: 4 additions & 5 deletions src/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl Display for Status {
}
}

#[derive(Serialize, Deserialize, Getters)]
#[derive(Serialize, Deserialize, Getters, Debug)]
pub struct OIDCAgentResponse {
status: Status,
}
Expand All @@ -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<Utc>,

#[serde(default, with = "chrono::serde::ts_seconds_option")]
expires_at: Option<DateTime<Utc>>,
mytoken_type: Option<MyTokenType>,
transfer_code: Option<String>,
expires_in: Option<u64>, //Number of seconds according to the Mytoken documentation
Expand Down

0 comments on commit 4d1df50

Please sign in to comment.