Keats / jsonwebtoken

JWT lib in rust
MIT License
1.62k stars 252 forks source link

Add validation against provided timestamp #319

Open jakubtrnka opened 1 year ago

jakubtrnka commented 1 year ago

Greetings,

I need to validate the Claims against unix timestamp that I provide to the library. I can't rely that the local system time is always correct.

Function

pub fn get_current_timestamp() -> u64 {
    let start = SystemTime::now();
    start.duration_since(UNIX_EPOCH).expect("Time went backwards").as_secs()
}

that is used in Your library is not sufficient for my use case.

I'm willing to implement it myself and submit PR if you're okay with the concept.

jakubtrnka commented 1 year ago

In the meantime I took the liberty and did it, because it's trivial.

https://github.com/Keats/jsonwebtoken/pull/320