Deny clippy::pedantic
Diff
jogre-server/src/main.rs | 3 +++
jogre-server/src/layers/auth_required.rs | 3 ++-
jogre-server/src/methods/session.rs | 9 +++++++--
jogre-server/src/store/rocksdb.rs | 5 +++--
jogre-server/src/methods/oauth/authorize.rs | 7 +++++++
jogre-server/src/methods/oauth/refresh.rs | 7 +++++++
jogre-server/src/methods/oauth/token.rs | 4 +++-
7 files changed, 29 insertions(+), 9 deletions(-)
@@ -1,3 +1,6 @@
#![deny(clippy::pedantic)]
#![allow(clippy::module_name_repetitions)]
mod config;
mod context;
mod layers;
@@ -7,6 +7,7 @@
response::{IntoResponse, Response},
RequestExt,
};
use oxide_auth::frontends::simple::endpoint;
use oxide_auth_axum::{OAuthResource, WebError};
use tracing::{debug, error};
@@ -29,7 +30,7 @@
Ok(v) => v,
Err(e) => {
error!("Rejecting request due to it being unauthorized");
return e.map_err(|e| e.pack::<WebError>()).into_response();
return e.map_err(endpoint::Error::pack::<WebError>).into_response();
}
};
@@ -1,4 +1,7 @@
use std::sync::{Arc, OnceLock};
use std::{
collections::{BTreeSet, HashMap},
sync::{Arc, OnceLock},
};
use axum::{extract::State, Extension, Json};
use jmap_proto::{
@@ -72,11 +75,11 @@
max_calls_in_request: context.core_capabilities.max_calls_in_request.into(),
max_objects_in_get: context.core_capabilities.max_objects_in_get.into(),
max_objects_in_set: context.core_capabilities.max_objects_in_set.into(),
collation_algorithms: Default::default(),
collation_algorithms: BTreeSet::default(),
},
},
accounts,
primary_accounts: Default::default(),
primary_accounts: HashMap::default(),
username: username.into(),
api_url: API_URL
.get_or_init(|| {
@@ -54,12 +54,13 @@
}
}
#[allow(clippy::unnecessary_wraps)]
fn rocksdb_merger(
_new_key: &[u8],
existing_val: Option<&[u8]>,
operands: &MergeOperands,
) -> Option<Vec<u8>> {
let mut new_val = existing_val.map(|v| v.to_vec()).unwrap_or_default();
let mut new_val = existing_val.map(<[u8]>::to_vec).unwrap_or_default();
for operand in operands {
let (operation, operand) = MergeOperation::parse(operand);
@@ -153,7 +154,7 @@
Ok(self
.db
.prefix_iterator_cf(access_handle, user_id.as_bytes())
.map(|v| v.unwrap())
.map(Result::unwrap)
.filter_map(|(key, _access_level)| {
let Some(account) = key.strip_prefix(user_id.as_bytes()) else {
panic!("got invalid key from rocksdb");
@@ -1,13 +1,18 @@
use std::sync::Arc;
use axum::extract::State;
use oxide_auth::frontends::simple::endpoint;
use oxide_auth_axum::{OAuthResponse, WebError};
use crate::context::{oauth2::OAuthRequestWrapper, Context};
#[allow(clippy::unused_async)]
pub async fn handle(
State(context): State<Arc<Context>>,
request: OAuthRequestWrapper,
) -> Result<OAuthResponse, WebError> {
context.oauth2.authorize(request).map_err(|e| e.pack())
context
.oauth2
.authorize(request)
.map_err(endpoint::Error::pack)
}
@@ -1,13 +1,18 @@
use std::sync::Arc;
use axum::extract::State;
use oxide_auth::frontends::simple::endpoint;
use oxide_auth_axum::{OAuthResponse, WebError};
use crate::context::{oauth2::OAuthRequestWrapper, Context};
#[allow(clippy::unused_async)]
pub async fn handle(
State(context): State<Arc<Context>>,
request: OAuthRequestWrapper,
) -> Result<OAuthResponse, WebError> {
context.oauth2.refresh(request).map_err(|e| e.pack())
context
.oauth2
.refresh(request)
.map_err(endpoint::Error::pack)
}
@@ -1,13 +1,15 @@
use std::sync::Arc;
use axum::extract::State;
use oxide_auth::frontends::simple::endpoint;
use oxide_auth_axum::{OAuthResponse, WebError};
use crate::context::{oauth2::OAuthRequestWrapper, Context};
#[allow(clippy::unused_async)]
pub async fn handle(
State(context): State<Arc<Context>>,
request: OAuthRequestWrapper,
) -> Result<OAuthResponse, WebError> {
context.oauth2.token(request).map_err(|e| e.pack())
context.oauth2.token(request).map_err(endpoint::Error::pack)
}