diff --git a/Cargo.toml b/Cargo.toml index 150c766..0719140 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,12 +10,12 @@ name = "beteran_common_rust" path = "./src/lib.rs" [dependencies] +chrono = { version = "0" } jsonwebtoken = { version = "8" } lazy_static = { version = "1" } prost = { version = "0" } serde = { version = "1", features = ["derive"] } serde_json = { version = "1" } -time = { version = "0.3" } beteran-protobuf-rust = { git = "https://gitlab.loafle.net/bet/beteran-protobuf-rust.git", tag = "v0.1.79-snapshot" } diff --git a/src/jwt/mod.rs b/src/jwt/mod.rs index e9cc2f5..f97bf22 100644 --- a/src/jwt/mod.rs +++ b/src/jwt/mod.rs @@ -50,12 +50,13 @@ pub fn encode(issuer: &str, session_id: &str) -> Result { let header = Header::new(Algorithm::RS256); - let issued_at = time::OffsetDateTime::now_utc(); - let expiration_at = issued_at + time::Duration::days(1); + let issued_at = (chrono::Utc::now()).timestamp(); + let expiration_at = (chrono::Utc::now() + chrono::Duration::days(1)).timestamp(); + let claims = Claims { iss: issuer.to_string(), - iat: issued_at.unix_timestamp(), - exp: expiration_at.unix_timestamp(), + iat: issued_at, + exp: expiration_at, session_id: session_id.to_string(), };