chore: Merge branch 'NotNorom/main' into main

This commit is contained in:
cduvray 2023-07-10 08:02:31 +02:00
commit 157cdfa396
3 changed files with 36 additions and 10 deletions

View file

@ -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"

View file

@ -1,17 +1,36 @@
use chrono::{DateTime, TimeZone, Utc};
use serde::Deserialize;
/// Seconds since the epoch
#[derive(Deserialize, Clone, PartialEq, Eq, Debug)]
pub struct NumericDate(i64);
impl NumericDate {
/// Get the underlying unix timestamp
pub fn inner(&self) -> i64 {
self.0
}
}
#[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, Deserialize)]
#[serde(untagged)]
pub enum OneOrArray<T> {
@ -28,6 +47,9 @@ impl<T> OneOrArray<T> {
}
}
#[derive(PartialEq, Debug, Clone)]
pub struct StringList(Vec<String>);
/// Claims mentioned in the JWT specifications.
///
/// https://www.rfc-editor.org/rfc/rfc7519#section-4.1