Unversioned archiving
This commit is contained in:
@@ -19,7 +19,7 @@ use std::future::Future;
|
||||
use store::{
|
||||
Serialize,
|
||||
dispatch::lookup::KeyValue,
|
||||
write::{Archive, Archiver},
|
||||
write::{UnversionedArchive, UnversionedArchiver},
|
||||
};
|
||||
use store::{
|
||||
rand::{
|
||||
@@ -109,7 +109,7 @@ impl OAuthApiHandler for Server {
|
||||
.collect::<String>();
|
||||
|
||||
// Serialize OAuth code
|
||||
let value = Archiver::new(OAuthCode {
|
||||
let value = UnversionedArchiver::new(OAuthCode {
|
||||
status: OAuthStatus::Authorized,
|
||||
account_id: access_token.primary_id(),
|
||||
client_id,
|
||||
@@ -151,7 +151,7 @@ impl OAuthApiHandler for Server {
|
||||
.core
|
||||
.storage
|
||||
.lookup
|
||||
.key_get::<Archive<AlignedBytes>>(KeyValue::<()>::build_key(
|
||||
.key_get::<UnversionedArchive<AlignedBytes>>(KeyValue::<()>::build_key(
|
||||
KV_OAUTH,
|
||||
code.as_bytes(),
|
||||
))
|
||||
@@ -185,7 +185,7 @@ impl OAuthApiHandler for Server {
|
||||
KeyValue::with_prefix(
|
||||
KV_OAUTH,
|
||||
oauth.params.as_bytes(),
|
||||
Archiver::new(new_oauth_code)
|
||||
UnversionedArchiver::new(new_oauth_code)
|
||||
.serialize()
|
||||
.caused_by(trc::location!())?,
|
||||
)
|
||||
@@ -243,7 +243,7 @@ impl OAuthApiHandler for Server {
|
||||
}
|
||||
|
||||
// Add OAuth status
|
||||
let oauth_code = Archiver::new(OAuthCode {
|
||||
let oauth_code = UnversionedArchiver::new(OAuthCode {
|
||||
status: OAuthStatus::Pending,
|
||||
account_id: u32::MAX,
|
||||
client_id,
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
use http_proto::{HttpRequest, request::fetch_body};
|
||||
use hyper::header::CONTENT_TYPE;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use store::{SERIALIZE_OAUTHCODE_V1, SerializedVersion};
|
||||
use utils::map::vec_map::VecMap;
|
||||
|
||||
pub mod auth;
|
||||
@@ -56,12 +55,6 @@ pub struct OAuthCode {
|
||||
pub params: String,
|
||||
}
|
||||
|
||||
impl SerializedVersion for OAuthCode {
|
||||
fn serialize_version() -> u8 {
|
||||
SERIALIZE_OAUTHCODE_V1
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct DeviceAuthGet {
|
||||
code: Option<String>,
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||
*/
|
||||
|
||||
use super::{
|
||||
ArchivedOAuthStatus, ErrorType, FormData, MAX_POST_LEN, OAuthCode, OAuthResponse, OAuthStatus,
|
||||
TokenResponse, registration::ClientRegistrationHandler,
|
||||
};
|
||||
use common::{
|
||||
KV_OAUTH, Server,
|
||||
auth::{
|
||||
@@ -11,22 +15,15 @@ use common::{
|
||||
oauth::{GrantType, oidc::StandardClaims},
|
||||
},
|
||||
};
|
||||
|
||||
use http_proto::*;
|
||||
use hyper::StatusCode;
|
||||
use std::future::Future;
|
||||
use store::{
|
||||
dispatch::lookup::KeyValue,
|
||||
write::{AlignedBytes, Archive},
|
||||
write::{AlignedBytes, UnversionedArchive},
|
||||
};
|
||||
use trc::AddContext;
|
||||
|
||||
use http_proto::*;
|
||||
|
||||
use super::{
|
||||
ArchivedOAuthStatus, ErrorType, FormData, MAX_POST_LEN, OAuthCode, OAuthResponse, OAuthStatus,
|
||||
TokenResponse, registration::ClientRegistrationHandler,
|
||||
};
|
||||
|
||||
pub trait TokenHandler: Sync + Send {
|
||||
fn handle_token_request(
|
||||
&self,
|
||||
@@ -80,7 +77,7 @@ impl TokenHandler for Server {
|
||||
.core
|
||||
.storage
|
||||
.lookup
|
||||
.key_get::<Archive<AlignedBytes>>(KeyValue::<()>::build_key(
|
||||
.key_get::<UnversionedArchive<AlignedBytes>>(KeyValue::<()>::build_key(
|
||||
KV_OAUTH,
|
||||
code.as_bytes(),
|
||||
))
|
||||
@@ -152,7 +149,7 @@ impl TokenHandler for Server {
|
||||
.core
|
||||
.storage
|
||||
.lookup
|
||||
.key_get::<Archive<AlignedBytes>>(KeyValue::<()>::build_key(
|
||||
.key_get::<UnversionedArchive<AlignedBytes>>(KeyValue::<()>::build_key(
|
||||
KV_OAUTH,
|
||||
device_code.as_bytes(),
|
||||
))
|
||||
|
||||
@@ -4,29 +4,27 @@
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||
*/
|
||||
|
||||
use std::future::Future;
|
||||
|
||||
use common::{Server, auth::AccessToken};
|
||||
|
||||
use directory::{Permission, Type, backend::internal::manage::ManageDirectory};
|
||||
use http_proto::{request::decode_path_element, *};
|
||||
use hyper::Method;
|
||||
use mail_auth::report::{
|
||||
Feedback,
|
||||
tlsrpt::{FailureDetails, Policy, TlsReport},
|
||||
};
|
||||
use serde_json::json;
|
||||
use smtp::reporting::{ReportSerializer, analysis::IncomingReport};
|
||||
use smtp::reporting::analysis::IncomingReport;
|
||||
use std::future::Future;
|
||||
use store::{
|
||||
Deserialize, IterateParams, Key, U64_LEN, ValueKey,
|
||||
write::{
|
||||
AlignedBytes, Archive, BatchBuilder, ReportClass, ValueClass, key::DeserializeBigEndian,
|
||||
AlignedBytes, BatchBuilder, ReportClass, UnversionedArchive, ValueClass,
|
||||
key::DeserializeBigEndian,
|
||||
},
|
||||
};
|
||||
use trc::AddContext;
|
||||
use utils::url_params::UrlParams;
|
||||
|
||||
use http_proto::{request::decode_path_element, *};
|
||||
|
||||
enum ReportType {
|
||||
Dmarc,
|
||||
Tls,
|
||||
@@ -291,10 +289,10 @@ where
|
||||
{
|
||||
if let Some(tls) = server
|
||||
.store()
|
||||
.get_value::<Archive<AlignedBytes>>(key)
|
||||
.get_value::<UnversionedArchive<AlignedBytes>>(key)
|
||||
.await?
|
||||
{
|
||||
tls.deserialize::<ReportSerializer<T>>().map(|v| Some(v.0))
|
||||
tls.deserialize::<T>().map(Some)
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
@@ -381,45 +379,39 @@ async fn fetch_incoming_reports(
|
||||
last_id = id;
|
||||
|
||||
// TODO: Support filtering chunked records (over 10MB) on FDB
|
||||
let archive = <Archive<AlignedBytes> as Deserialize>::deserialize(value)?;
|
||||
let archive =
|
||||
<UnversionedArchive<AlignedBytes> as Deserialize>::deserialize(value)?;
|
||||
let matches = if has_filters {
|
||||
match typ {
|
||||
ReportType::Dmarc => {
|
||||
let report =
|
||||
archive
|
||||
.deserialize::<ReportSerializer<IncomingReport<mail_auth::report::Report>>>()
|
||||
.caused_by(trc::location!())?
|
||||
.0;
|
||||
let report = archive
|
||||
.deserialize::<IncomingReport<mail_auth::report::Report>>()
|
||||
.caused_by(trc::location!())?;
|
||||
|
||||
filter.is_none_or( |f| report.contains(f))
|
||||
filter.is_none_or(|f| report.contains(f))
|
||||
&& tenant_domains
|
||||
.as_ref()
|
||||
.is_none_or( |domains| report.has_domain(domains))
|
||||
.is_none_or(|domains| report.has_domain(domains))
|
||||
}
|
||||
ReportType::Tls => {
|
||||
let report =
|
||||
archive
|
||||
.deserialize::<ReportSerializer<IncomingReport<TlsReport>>>()
|
||||
.caused_by(trc::location!())?
|
||||
.0;
|
||||
let report = archive
|
||||
.deserialize::<IncomingReport<TlsReport>>()
|
||||
.caused_by(trc::location!())?;
|
||||
|
||||
filter.is_none_or( |f| report.contains(f))
|
||||
filter.is_none_or(|f| report.contains(f))
|
||||
&& tenant_domains
|
||||
.as_ref()
|
||||
.is_none_or( |domains| report.has_domain(domains))
|
||||
.is_none_or(|domains| report.has_domain(domains))
|
||||
}
|
||||
ReportType::Arf => {
|
||||
let report =
|
||||
archive
|
||||
.deserialize::<ReportSerializer<IncomingReport<Feedback>>>()
|
||||
.caused_by(trc::location!())?
|
||||
.0;
|
||||
let report = archive
|
||||
.deserialize::<IncomingReport<Feedback>>()
|
||||
.caused_by(trc::location!())?;
|
||||
|
||||
|
||||
filter.is_none_or( |f| report.contains(f))
|
||||
filter.is_none_or(|f| report.contains(f))
|
||||
&& tenant_domains
|
||||
.as_ref()
|
||||
.is_none_or( |domains| report.has_domain(domains))
|
||||
.is_none_or(|domains| report.has_domain(domains))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user