From 9e6572fa282a18fecfb31a2c35c17c0e8c23e371 Mon Sep 17 00:00:00 2001 From: pennae Date: Mon, 25 Jul 2022 02:26:35 +0200 Subject: remove dependency on chrono prompted by a cargo audit run. time works just as well and is better maintained. web-push still uses chrono, but from the looks of things it won't be affected. --- src/api/auth/oauth.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/api/auth/oauth.rs') diff --git a/src/api/auth/oauth.rs b/src/api/auth/oauth.rs index 384d4b4..25d6150 100644 --- a/src/api/auth/oauth.rs +++ b/src/api/auth/oauth.rs @@ -1,11 +1,11 @@ use std::collections::HashMap; -use chrono::{DateTime, Duration, Local, Utc}; use rocket::serde::json::Json; use serde::{Deserialize, Serialize}; use serde_json::Value; use sha2::Digest; use subtle::ConstantTimeEq; +use time::{Duration, OffsetDateTime}; use crate::api::auth::WithVerifiedFxaLogin; use crate::api::{Empty, EMPTY}; @@ -13,7 +13,7 @@ use crate::crypto::SessionToken; use crate::db::DbConn; use crate::types::oauth::{Scope, ScopeSet}; use crate::{ - api::{auth, serialize_dt}, + api::auth, auth::Authenticated, crypto::SessionCredentials, types::{ @@ -283,8 +283,8 @@ pub(crate) struct TokenResp { scope: ScopeSet, token_type: TokenType, expires_in: u32, - #[serde(serialize_with = "serialize_dt")] - auth_at: DateTime, + #[serde(with = "time::serde::timestamp")] + auth_at: OffsetDateTime, #[serde(skip_serializing_if = "Option::is_none")] keys_jwe: Option, } @@ -328,7 +328,7 @@ pub(crate) async fn token_unauthenticated( async fn token_impl( db: &DbConn, user_id: Option, - auth_at: Option>, + auth_at: Option, req: TokenReq, parent_refresh: Option, parent_session: Option, @@ -385,7 +385,7 @@ async fn token_impl( scope: scope.clone(), parent_refresh, parent_session, - expires_at: (Local::now() + Duration::seconds(ttl.into())).into(), + expires_at: OffsetDateTime::now_utc() + Duration::seconds(ttl.into()), }, ) .await?; -- cgit v1.2.3