Skip to content

Commit

Permalink
timestamp annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
Wiktor Nastał committed Jun 18, 2024
1 parent 9bdd252 commit 36c22de
Show file tree
Hide file tree
Showing 5 changed files with 258 additions and 8 deletions.
247 changes: 247 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
chrono = { version = "0.4.38", features = ["serde"] }
serde = { version = "1.0.203", features = ["derive"] }
serde_json = "1.0.117"
url = { version = "2.5.1", features = ["serde"] }
2 changes: 1 addition & 1 deletion src/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct AccessTokenRequest {
request: RequestType,
account: Option<String>,
issuer: Option<Url>,
min_valid_period: Option<usize>,
min_valid_period: Option<u64>, //Always seconds
application_hint: Option<String>,
scope: Option<String>,
audience: Option<String>,
Expand Down
15 changes: 8 additions & 7 deletions src/responses.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::Response;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use std::error::Error;
use std::fmt::Display;
Expand Down Expand Up @@ -35,7 +36,9 @@ impl OIDCAgentResponse {
pub struct AccessTokenResponse {
pub access_token: String,
issuer: Url,
expires_at: usize,

#[serde(with = "chrono::serde::ts_seconds")]
expires_at: DateTime<Utc>,
}

impl Response for AccessTokenResponse {}
Expand All @@ -45,7 +48,9 @@ pub struct MytokenResponse {
pub mytoken: String,
mytoken_issuer: Url,
oidc_issuer: Url,
expires_at: usize,

#[serde(with = "chrono::serde::ts_seconds")]
expires_at: DateTime<Utc>,
}

impl Response for MytokenResponse {}
Expand Down Expand Up @@ -73,8 +78,4 @@ impl Display for OIDCAgentError {
}
}

impl Error for OIDCAgentError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
None
}
}
impl Error for OIDCAgentError {}
1 change: 1 addition & 0 deletions tests/basic.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use oidc_agent_rs::*;

#[test]
fn test_basic() {
let client = Client::new().unwrap();
Expand Down

0 comments on commit 36c22de

Please sign in to comment.