diff options
Diffstat (limited to 'src/api/auth/mod.rs')
-rw-r--r-- | src/api/auth/mod.rs | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/src/api/auth/mod.rs b/src/api/auth/mod.rs index d50dcc2..a2a94e0 100644 --- a/src/api/auth/mod.rs +++ b/src/api/auth/mod.rs @@ -8,8 +8,7 @@ use serde_json::json; use crate::{ auth::Authenticated, - crypto::SecretBytes, - types::{OauthToken, SessionID, UserSession}, + types::{HawkKey, OauthToken, SessionID, UserSession}, }; pub(crate) mod account; @@ -140,13 +139,10 @@ pub(crate) struct WithFxaLogin; impl crate::auth::AuthSource for WithFxaLogin { type ID = SessionID; type Context = UserSession; - async fn hawk( - r: &Request<'_>, - id: &SessionID, - ) -> anyhow::Result<(SecretBytes<32>, Self::Context)> { + 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((SecretBytes(k.req_hmac_key.0), k)) + Ok((k.req_hmac_key.clone(), k)) } async fn bearer_token( _: &Request<'_>, @@ -163,10 +159,7 @@ pub(crate) struct WithVerifiedFxaLogin; impl crate::auth::AuthSource for WithVerifiedFxaLogin { type ID = SessionID; type Context = UserSession; - async fn hawk( - r: &Request<'_>, - id: &SessionID, - ) -> anyhow::Result<(SecretBytes<32>, Self::Context)> { + async fn hawk(r: &Request<'_>, id: &SessionID) -> anyhow::Result<(HawkKey, Self::Context)> { let res = WithFxaLogin::hawk(r, id).await?; match res.1.verified { true => Ok(res), @@ -191,10 +184,7 @@ pub(crate) struct WithSession; impl crate::auth::AuthSource for WithSession { type ID = SessionID; type Context = UserSession; - async fn hawk( - r: &Request<'_>, - id: &SessionID, - ) -> anyhow::Result<(SecretBytes<32>, Self::Context)> { + async fn hawk(r: &Request<'_>, id: &SessionID) -> anyhow::Result<(HawkKey, Self::Context)> { WithFxaLogin::hawk(r, id).await } async fn bearer_token( @@ -213,10 +203,7 @@ pub(crate) struct WithVerifiedSession; impl crate::auth::AuthSource for WithVerifiedSession { type ID = SessionID; type Context = UserSession; - async fn hawk( - r: &Request<'_>, - id: &SessionID, - ) -> anyhow::Result<(SecretBytes<32>, Self::Context)> { + async fn hawk(r: &Request<'_>, id: &SessionID) -> anyhow::Result<(HawkKey, Self::Context)> { WithVerifiedFxaLogin::hawk(r, id).await } async fn bearer_token( |