mirror of
https://github.com/zhaofengli/attic.git
synced 2024-12-14 11:57:30 +00:00
token: fixup JWT creation
Since we now validate the `sub` and `nbf` claims, they need to be set when atticadm generates them.
This commit is contained in:
parent
fcc049495e
commit
9e23916e02
3 changed files with 25 additions and 35 deletions
54
Cargo.lock
generated
54
Cargo.lock
generated
|
@ -66,6 +66,12 @@ dependencies = [
|
|||
"alloc-no-stdlib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "android-tzdata"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
|
||||
|
||||
[[package]]
|
||||
name = "android_system_properties"
|
||||
version = "0.1.5"
|
||||
|
@ -363,7 +369,7 @@ dependencies = [
|
|||
"http",
|
||||
"hyper",
|
||||
"ring 0.16.20",
|
||||
"time 0.3.21",
|
||||
"time",
|
||||
"tokio",
|
||||
"tower",
|
||||
"tracing",
|
||||
|
@ -533,7 +539,7 @@ dependencies = [
|
|||
"percent-encoding",
|
||||
"regex",
|
||||
"sha2",
|
||||
"time 0.3.21",
|
||||
"time",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
|
@ -673,7 +679,7 @@ dependencies = [
|
|||
"itoa",
|
||||
"num-integer",
|
||||
"ryu",
|
||||
"time 0.3.21",
|
||||
"time",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -975,18 +981,17 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.24"
|
||||
version = "0.4.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b"
|
||||
checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38"
|
||||
dependencies = [
|
||||
"android-tzdata",
|
||||
"iana-time-zone",
|
||||
"js-sys",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
"serde",
|
||||
"time 0.1.45",
|
||||
"wasm-bindgen",
|
||||
"winapi",
|
||||
"windows-targets 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1684,7 +1689,7 @@ checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427"
|
|||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2258,7 +2263,7 @@ checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9"
|
|||
dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||
"wasi",
|
||||
"windows-sys 0.45.0",
|
||||
]
|
||||
|
||||
|
@ -3065,7 +3070,7 @@ dependencies = [
|
|||
"serde_json",
|
||||
"sqlx",
|
||||
"thiserror",
|
||||
"time 0.3.21",
|
||||
"time",
|
||||
"tracing",
|
||||
"url",
|
||||
"uuid",
|
||||
|
@ -3128,7 +3133,7 @@ dependencies = [
|
|||
"rust_decimal",
|
||||
"sea-query-derive",
|
||||
"serde_json",
|
||||
"time 0.3.21",
|
||||
"time",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
|
@ -3144,7 +3149,7 @@ dependencies = [
|
|||
"sea-query",
|
||||
"serde_json",
|
||||
"sqlx",
|
||||
"time 0.3.21",
|
||||
"time",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
|
@ -3315,7 +3320,7 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_json",
|
||||
"serde_with_macros",
|
||||
"time 0.3.21",
|
||||
"time",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3424,7 +3429,7 @@ dependencies = [
|
|||
"num-bigint",
|
||||
"num-traits",
|
||||
"thiserror",
|
||||
"time 0.3.21",
|
||||
"time",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3551,7 +3556,7 @@ dependencies = [
|
|||
"sqlx-rt",
|
||||
"stringprep",
|
||||
"thiserror",
|
||||
"time 0.3.21",
|
||||
"time",
|
||||
"tokio-stream",
|
||||
"url",
|
||||
"uuid",
|
||||
|
@ -3703,17 +3708,6 @@ dependencies = [
|
|||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.1.45"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"wasi 0.10.0+wasi-snapshot-preview1",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.21"
|
||||
|
@ -4215,12 +4209,6 @@ dependencies = [
|
|||
"try-lock",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
|
|
|
@ -9,7 +9,7 @@ edition = "2021"
|
|||
attic = { path = "../attic", default-features = false }
|
||||
|
||||
base64 = "0.21.2"
|
||||
chrono = "0.4.24"
|
||||
chrono = "0.4.31"
|
||||
displaydoc = "0.2.4"
|
||||
jsonwebtoken = { version = "9.1.0", features = ["use_pem"] }
|
||||
lazy_static = "1.4.0"
|
||||
|
|
|
@ -319,10 +319,12 @@ impl Token {
|
|||
attic_ns: Default::default(),
|
||||
};
|
||||
|
||||
let now_epoch = Utc::now().signed_duration_since(DateTime::UNIX_EPOCH);
|
||||
|
||||
Self(JWTClaims {
|
||||
issued_at: None,
|
||||
expires_at: Some(exp.timestamp()),
|
||||
invalid_before: None,
|
||||
invalid_before: Some(now_epoch.num_seconds()),
|
||||
issuer: None,
|
||||
subject: Some(sub),
|
||||
audiences: None,
|
||||
|
|
Loading…
Reference in a new issue