diff options
author | pennae <github@quasiparticle.net> | 2022-07-25 02:26:35 +0200 |
---|---|---|
committer | pennae <github@quasiparticle.net> | 2022-07-25 02:45:55 +0200 |
commit | 9e6572fa282a18fecfb31a2c35c17c0e8c23e371 (patch) | |
tree | c4ead0f54601fe010e2e17b0a8b43f6362b1c1a4 /src/api/auth/oauth.rs | |
parent | 9aacaaf079373f8bc25f0533d7f6218e691c5de7 (diff) | |
download | minor-skulk-9e6572fa282a18fecfb31a2c35c17c0e8c23e371.tar.gz minor-skulk-9e6572fa282a18fecfb31a2c35c17c0e8c23e371.tar.xz minor-skulk-9e6572fa282a18fecfb31a2c35c17c0e8c23e371.zip |
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.
Diffstat (limited to 'src/api/auth/oauth.rs')
-rw-r--r-- | src/api/auth/oauth.rs | 12 |
1 files changed, 6 insertions, 6 deletions
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<Utc>, + #[serde(with = "time::serde::timestamp")] + auth_at: OffsetDateTime, #[serde(skip_serializing_if = "Option::is_none")] keys_jwe: Option<String>, } @@ -328,7 +328,7 @@ pub(crate) async fn token_unauthenticated( async fn token_impl( db: &DbConn, user_id: Option<UserID>, - auth_at: Option<DateTime<Utc>>, + auth_at: Option<OffsetDateTime>, req: TokenReq, parent_refresh: Option<OauthTokenID>, parent_session: Option<SessionID>, @@ -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?; |