Include integrity hash in serialized bytes
This commit is contained in:
@@ -16,16 +16,19 @@ use common::{
|
||||
use serde::Deserialize;
|
||||
use serde_json::json;
|
||||
use std::future::Future;
|
||||
use store::rand::{
|
||||
Rng,
|
||||
distr::{Alphanumeric, StandardUniform},
|
||||
rng,
|
||||
};
|
||||
use store::{
|
||||
Serialize,
|
||||
dispatch::lookup::KeyValue,
|
||||
write::{Archive, Archiver},
|
||||
};
|
||||
use store::{
|
||||
rand::{
|
||||
Rng,
|
||||
distr::{Alphanumeric, StandardUniform},
|
||||
rng,
|
||||
},
|
||||
write::AlignedBytes,
|
||||
};
|
||||
use trc::AddContext;
|
||||
|
||||
use crate::auth::oauth::OAuthStatus;
|
||||
@@ -148,7 +151,10 @@ impl OAuthApiHandler for Server {
|
||||
.core
|
||||
.storage
|
||||
.lookup
|
||||
.key_get::<Archive>(KeyValue::<()>::build_key(KV_OAUTH, code.as_bytes()))
|
||||
.key_get::<Archive<AlignedBytes>>(KeyValue::<()>::build_key(
|
||||
KV_OAUTH,
|
||||
code.as_bytes(),
|
||||
))
|
||||
.await?
|
||||
{
|
||||
let oauth = auth_code_
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
use http_proto::{HttpRequest, request::fetch_body};
|
||||
use hyper::header::CONTENT_TYPE;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use store::SerializedVersion;
|
||||
use utils::map::vec_map::VecMap;
|
||||
|
||||
pub mod auth;
|
||||
@@ -55,6 +56,12 @@ pub struct OAuthCode {
|
||||
pub params: String,
|
||||
}
|
||||
|
||||
impl SerializedVersion for OAuthCode {
|
||||
fn serialize_version() -> u8 {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct DeviceAuthGet {
|
||||
code: Option<String>,
|
||||
|
||||
@@ -13,7 +13,10 @@ use common::{
|
||||
};
|
||||
use hyper::StatusCode;
|
||||
use std::future::Future;
|
||||
use store::{dispatch::lookup::KeyValue, write::Archive};
|
||||
use store::{
|
||||
dispatch::lookup::KeyValue,
|
||||
write::{AlignedBytes, Archive},
|
||||
};
|
||||
use trc::AddContext;
|
||||
|
||||
use http_proto::*;
|
||||
@@ -76,7 +79,10 @@ impl TokenHandler for Server {
|
||||
.core
|
||||
.storage
|
||||
.lookup
|
||||
.key_get::<Archive>(KeyValue::<()>::build_key(KV_OAUTH, code.as_bytes()))
|
||||
.key_get::<Archive<AlignedBytes>>(KeyValue::<()>::build_key(
|
||||
KV_OAUTH,
|
||||
code.as_bytes(),
|
||||
))
|
||||
.await?
|
||||
{
|
||||
Some(auth_code_) => {
|
||||
@@ -145,7 +151,10 @@ impl TokenHandler for Server {
|
||||
.core
|
||||
.storage
|
||||
.lookup
|
||||
.key_get::<Archive>(KeyValue::<()>::build_key(KV_OAUTH, device_code.as_bytes()))
|
||||
.key_get::<Archive<AlignedBytes>>(KeyValue::<()>::build_key(
|
||||
KV_OAUTH,
|
||||
device_code.as_bytes(),
|
||||
))
|
||||
.await?
|
||||
{
|
||||
let oauth = auth_code_
|
||||
|
||||
@@ -19,7 +19,7 @@ use mail_parser::MessageParser;
|
||||
use serde_json::json;
|
||||
use store::{
|
||||
Deserialize, Serialize,
|
||||
write::{Archive, Archiver, BatchBuilder},
|
||||
write::{AlignedBytes, Archive, Archiver, BatchBuilder},
|
||||
};
|
||||
use trc::AddContext;
|
||||
|
||||
@@ -39,7 +39,7 @@ pub trait CryptoHandler: Sync + Send {
|
||||
impl CryptoHandler for Server {
|
||||
async fn handle_crypto_get(&self, access_token: Arc<AccessToken>) -> trc::Result<HttpResponse> {
|
||||
let ec = if let Some(params_) = self
|
||||
.get_property::<Archive>(
|
||||
.get_property::<Archive<AlignedBytes>>(
|
||||
access_token.primary_id(),
|
||||
Collection::Principal,
|
||||
0,
|
||||
@@ -132,7 +132,7 @@ impl CryptoHandler for Server {
|
||||
.parse("Subject: test\r\ntest\r\n".as_bytes())
|
||||
.unwrap()
|
||||
.encrypt(
|
||||
<Archive as Deserialize>::deserialize(params.as_slice())?
|
||||
<Archive<AlignedBytes> as Deserialize>::deserialize(params.as_slice())?
|
||||
.unarchive::<EncryptionParams>()?,
|
||||
)
|
||||
.await
|
||||
|
||||
@@ -30,7 +30,9 @@ use smtp::{
|
||||
};
|
||||
use store::{
|
||||
Deserialize, IterateParams, ValueKey,
|
||||
write::{Archive, QueueClass, ReportEvent, ValueClass, key::DeserializeBigEndian, now},
|
||||
write::{
|
||||
AlignedBytes, Archive, QueueClass, ReportEvent, ValueClass, key::DeserializeBigEndian, now,
|
||||
},
|
||||
};
|
||||
use trc::AddContext;
|
||||
use utils::url_params::UrlParams;
|
||||
@@ -713,7 +715,7 @@ async fn fetch_queued_messages(
|
||||
.iterate(
|
||||
IterateParams::new(from_key, to_key).ascending(),
|
||||
|key, value| {
|
||||
let message_ = <Archive as Deserialize>::deserialize(value)
|
||||
let message_ = <Archive<AlignedBytes> as Deserialize>::deserialize(value)
|
||||
.add_context(|ctx| ctx.ctx(trc::Key::Key, key))?;
|
||||
let message = message_
|
||||
.unarchive::<queue::Message>()
|
||||
|
||||
@@ -23,7 +23,7 @@ use serde_json::json;
|
||||
use services::index::Indexer;
|
||||
use store::{
|
||||
Serialize, rand,
|
||||
write::{Archive, Archiver, BatchBuilder, ValueClass, assert::HashedValue},
|
||||
write::{AlignedBytes, Archive, Archiver, BatchBuilder, ValueClass},
|
||||
};
|
||||
use trc::AddContext;
|
||||
use utils::url_params::UrlParams;
|
||||
@@ -332,7 +332,7 @@ pub async fn reset_imap_uids(server: &Server, account_id: u32) -> trc::Result<(u
|
||||
.unwrap_or_default()
|
||||
{
|
||||
let mailbox = server
|
||||
.get_property::<HashedValue<Archive>>(
|
||||
.get_property::<Archive<AlignedBytes>>(
|
||||
account_id,
|
||||
Collection::Mailbox,
|
||||
mailbox_id,
|
||||
@@ -373,7 +373,7 @@ pub async fn reset_imap_uids(server: &Server, account_id: u32) -> trc::Result<(u
|
||||
.unwrap_or_default()
|
||||
{
|
||||
let uids = server
|
||||
.get_property::<HashedValue<Archive>>(
|
||||
.get_property::<Archive<AlignedBytes>>(
|
||||
account_id,
|
||||
Collection::Email,
|
||||
message_id,
|
||||
|
||||
Reference in New Issue
Block a user