From 3eda99e9efbdfc2cb0e20932f20018d53baf5a64 Mon Sep 17 00:00:00 2001 From: pennae Date: Sun, 17 Jul 2022 17:32:54 +0200 Subject: make the Clone bytes types Copy as well u8 arrays are copy, no need to not have our wrappers be copy. --- src/api/auth/account.rs | 18 +++++------------- src/api/auth/device.rs | 4 ++-- src/api/auth/mod.rs | 2 +- src/api/auth/oauth.rs | 7 +++---- 4 files changed, 11 insertions(+), 20 deletions(-) (limited to 'src/api/auth') diff --git a/src/api/auth/account.rs b/src/api/auth/account.rs index 9d2a19e..8f3ac55 100644 --- a/src/api/auth/account.rs +++ b/src/api/auth/account.rs @@ -100,10 +100,9 @@ pub(crate) async fn create( let key_fetch_token = if keys { let key_fetch_token = KeyFetchToken::generate(); let req = KeyFetchReq::derive_from(&key_fetch_token); - let wrapped = req.derive_resp().wrap_keys(&KeyBundle { - ka: ka.clone(), - wrap_kb: stretched.decrypt_wwkb(&wrapwrap_kb), - }); + let wrapped = req + .derive_resp() + .wrap_keys(&KeyBundle { ka, wrap_kb: stretched.decrypt_wwkb(&wrapwrap_kb) }); db.add_key_fetch(req.token_id, &req.req_hmac_key, &wrapped).await?; Some(key_fetch_token) } else { @@ -120,8 +119,7 @@ pub(crate) async fn create( verified: false, }) .await?; - let auth_at = - db.add_session(session.token_id.clone(), &uid, session.req_hmac_key, false, None).await?; + let auth_at = db.add_session(session.token_id, &uid, session.req_hmac_key, false, None).await?; let verify_code = hex::encode(&random_bytes::<16>()); db.add_verify_code(&uid, &session.token_id, &verify_code).await?; // NOTE we send the email in this context rather than a spawn to signal @@ -215,13 +213,7 @@ pub(crate) async fn login( let verify_code = format!("{:06}", thread_rng().gen_range(0..=999999)); let auth_at = db - .add_session( - session.token_id.clone(), - &uid, - session.req_hmac_key, - false, - Some(&verify_code), - ) + .add_session(session.token_id, &uid, session.req_hmac_key, false, Some(&verify_code)) .await?; // NOTE we send the email in this context rather than a spawn to signal // send errors to the client. diff --git a/src/api/auth/device.rs b/src/api/auth/device.rs index 2b05e12..44fbd2a 100644 --- a/src/api/auth/device.rs +++ b/src/api/auth/device.rs @@ -130,9 +130,9 @@ pub(crate) async fn device( let (own_id, changed_id, notify) = match (dev.id, data.context.device_id) { (None, None) => { let new = DeviceID::random(); - (Some(new.clone()), new, true) + (Some(new), new, true) }, - (None, Some(own)) => (Some(own.clone()), own, false), + (None, Some(own)) => (Some(own), own, false), (Some(other), own) => (own, other, false), }; let result = db diff --git a/src/api/auth/mod.rs b/src/api/auth/mod.rs index a2a94e0..5c4f973 100644 --- a/src/api/auth/mod.rs +++ b/src/api/auth/mod.rs @@ -142,7 +142,7 @@ impl crate::auth::AuthSource for WithFxaLogin { async fn hawk(r: &Request<'_>, id: &SessionID) -> anyhow::Result<(HawkKey, Self::Context)> { let db = Authenticated::<(), Self>::get_conn(r).await?; let k = db.use_session(id).await?; - Ok((k.req_hmac_key.clone(), k)) + Ok((k.req_hmac_key, k)) } async fn bearer_token( _: &Request<'_>, diff --git a/src/api/auth/oauth.rs b/src/api/auth/oauth.rs index 28d9fb2..384d4b4 100644 --- a/src/api/auth/oauth.rs +++ b/src/api/auth/oauth.rs @@ -304,7 +304,7 @@ pub(crate) async fn token_authenticated( Some(req.context.created_at), req.body, None, - Some(req.session.clone()), + Some(req.session), ) .await } @@ -380,7 +380,7 @@ async fn token_impl( db.add_access_token( &access_token.hash(), OauthAccessToken { - user_id: user_id.clone(), + user_id, client_id: req.client_id.clone(), scope: scope.clone(), parent_refresh, @@ -394,8 +394,7 @@ async fn token_impl( let (session_token, session_id) = if scope.implies(&SESSION_SCOPE) { let session_token = SessionToken::generate(); let session = SessionCredentials::derive_from(&session_token); - db.add_session(session.token_id.clone(), &user_id, session.req_hmac_key, true, None) - .await?; + db.add_session(session.token_id, &user_id, session.req_hmac_key, true, None).await?; (Some(session_token), Some(session.token_id)) } else { (None, None) -- cgit v1.2.3