mirror of
https://github.com/TECHNOFAB11/jwt-authorizer.git
synced 2025-12-12 08:00:07 +01:00
Add support for time crate.
This commit is contained in:
parent
7f9ad54694
commit
70d1ac3786
3 changed files with 24 additions and 7 deletions
|
|
@ -11,7 +11,7 @@ keywords = ["jwt","axum","authorisation","jwks"]
|
|||
|
||||
[dependencies]
|
||||
axum = { version = "0.6", features = ["headers"] }
|
||||
chrono = "0.4"
|
||||
chrono = { version = "0.4", optional = true }
|
||||
futures-util = "0.3"
|
||||
futures-core = "0.3"
|
||||
headers = "0.3"
|
||||
|
|
@ -29,6 +29,7 @@ tower-service = "0.3"
|
|||
tracing = "0.1"
|
||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||
tonic = { version = "0.9.2", optional = true }
|
||||
time = { version = "0.3.22", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
hyper = { version = "0.14", features = ["full"] }
|
||||
|
|
@ -38,7 +39,7 @@ tower = { version = "0.4", features = ["util", "buffer"] }
|
|||
wiremock = "0.5"
|
||||
|
||||
[features]
|
||||
default = ["default-tls"]
|
||||
default = ["default-tls", "chrono"]
|
||||
default-tls = ["reqwest/default-tls"]
|
||||
native-tls = ["reqwest/native-tls"]
|
||||
native-tls-vendored = ["reqwest/native-tls-vendored"]
|
||||
|
|
@ -47,6 +48,8 @@ rustls-tls = ["reqwest/rustls-tls"]
|
|||
rustls-tls-manual-roots = ["reqwest/rustls-tls-manual-roots"]
|
||||
rustls-tls-webpki-roots = ["reqwest/rustls-tls-webpki-roots"]
|
||||
rustls-tls-native-roots = ["reqwest/rustls-tls-native-roots"]
|
||||
time = ["dep:time"]
|
||||
chrono = ["dep:chrono"]
|
||||
|
||||
[[test]]
|
||||
name = "tonic"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
use chrono::{DateTime, TimeZone, Utc};
|
||||
use std::fmt;
|
||||
|
||||
use serde::{de, Deserialize, Deserializer};
|
||||
|
|
@ -7,12 +6,26 @@ use serde::{de, Deserialize, Deserializer};
|
|||
#[derive(Deserialize, Clone, PartialEq, Eq, Debug)]
|
||||
pub struct NumericDate(i64);
|
||||
|
||||
#[cfg(feature = "chrono")]
|
||||
use chrono::{DateTime, TimeZone, Utc};
|
||||
|
||||
#[cfg(feature = "chrono")]
|
||||
impl From<NumericDate> for DateTime<Utc> {
|
||||
fn from(t: NumericDate) -> Self {
|
||||
Utc.timestamp_opt(t.0, 0).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "time")]
|
||||
use time::OffsetDateTime;
|
||||
|
||||
#[cfg(feature = "time")]
|
||||
impl From<NumericDate> for OffsetDateTime {
|
||||
fn from(t: NumericDate) -> Self {
|
||||
OffsetDateTime::from_unix_timestamp(t.0).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Debug, Clone)]
|
||||
pub struct StringList(Vec<String>);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue