mirror of
https://github.com/TECHNOFAB11/jwt-authorizer.git
synced 2025-12-12 08:00:07 +01:00
chore: Merge branch 'NotNorom/main' into main
This commit is contained in:
commit
157cdfa396
3 changed files with 36 additions and 10 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue