Update deps and denormalize axum_extra::protobuf dep.

This commit is contained in:
Sebastian Jeltsch
2025-07-02 11:12:25 +02:00
parent cea697830e
commit 7bab041733
7 changed files with 168 additions and 62 deletions

123
Cargo.lock generated
View File

@@ -651,29 +651,6 @@ dependencies = [
"tracing",
]
[[package]]
name = "axum-extra"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45bf463831f5131b7d3c756525b305d40f1185b688565648a92e1392ca35713d"
dependencies = [
"axum 0.8.4",
"axum-core 0.5.2",
"bytes",
"futures-util",
"http",
"http-body",
"http-body-util",
"mime",
"pin-project-lite",
"prost",
"rustversion",
"serde",
"tower 0.5.2",
"tower-layer",
"tower-service",
]
[[package]]
name = "axum-test"
version = "17.3.0"
@@ -2651,9 +2628,9 @@ dependencies = [
[[package]]
name = "h2"
version = "0.4.10"
version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9421a676d1b147b16b82c9225157dc629087ef8ec4d5e2960f9437a90dac0a5"
checksum = "17da50a276f1e01e0ba6c029e47b7100754904ee8a278f886546e98575380785"
dependencies = [
"atomic-waker",
"bytes",
@@ -3153,6 +3130,17 @@ dependencies = [
"generic-array",
]
[[package]]
name = "io-uring"
version = "0.7.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b86e202f00093dcba4275d4636b93ef9dd75d025ae560d2521b45ea28ab49013"
dependencies = [
"bitflags",
"cfg-if",
"libc",
]
[[package]]
name = "ipconfig"
version = "0.3.2"
@@ -3627,9 +3615,9 @@ dependencies = [
[[package]]
name = "minijinja"
version = "2.10.2"
version = "2.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd72e8b4e42274540edabec853f607c015c73436159b06c39c7af85a20433155"
checksum = "4e60ac08614cc09062820e51d5d94c2fce16b94ea4e5003bb81b99a95f84e876"
dependencies = [
"serde",
]
@@ -4059,7 +4047,7 @@ dependencies = [
"opentelemetry-http",
"opentelemetry-proto",
"opentelemetry_sdk",
"prost",
"prost 0.13.5",
"serde_json",
"thiserror 1.0.69",
"tokio",
@@ -4076,7 +4064,7 @@ dependencies = [
"hex",
"opentelemetry",
"opentelemetry_sdk",
"prost",
"prost 0.13.5",
"serde",
"tonic",
]
@@ -4547,14 +4535,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2796faa41db3ec313a31f7624d9286acf277b52de526150b7e69f3debf891ee5"
dependencies = [
"bytes",
"prost-derive",
"prost-derive 0.13.5",
]
[[package]]
name = "prost"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7231bd9b3d3d33c86b58adbac74b5ec0ad9f496b19d22801d773636feaa95f3d"
dependencies = [
"bytes",
"prost-derive 0.14.1",
]
[[package]]
name = "prost-build"
version = "0.13.5"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be769465445e8c1474e9c5dac2018218498557af32d9ed057325ec9a41ae81bf"
checksum = "ac6c3320f9abac597dcbc668774ef006702672474aad53c6d596b62e487b40b1"
dependencies = [
"heck 0.5.0",
"itertools 0.14.0",
@@ -4563,7 +4561,7 @@ dependencies = [
"once_cell",
"petgraph",
"prettyplease",
"prost",
"prost 0.14.1",
"prost-types",
"regex",
"syn 2.0.104",
@@ -4584,22 +4582,35 @@ dependencies = [
]
[[package]]
name = "prost-reflect"
version = "0.15.3"
name = "prost-derive"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37587d5a8a1b3dc9863403d084fc2254b91ab75a702207098837950767e2260b"
checksum = "9120690fafc389a67ba3803df527d0ec9cbbc9cc45e4cc20b332996dfb672425"
dependencies = [
"anyhow",
"itertools 0.14.0",
"proc-macro2",
"quote",
"syn 2.0.104",
]
[[package]]
name = "prost-reflect"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e6b545c556471033fc1099868fca468bff8cf034f7bb9153b445f24d00aa28d"
dependencies = [
"logos",
"prost",
"prost 0.14.1",
"prost-reflect-derive",
"prost-types",
]
[[package]]
name = "prost-reflect-build"
version = "0.15.2"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad8db7191445b1dbee19df4f6b6294e5123aef52620b344a630bb845d302622a"
checksum = "8214ae2c30bbac390db0134d08300e770ef89b6d4e5abf855e8d300eded87e28"
dependencies = [
"prost-build",
"prost-reflect",
@@ -4607,9 +4618,9 @@ dependencies = [
[[package]]
name = "prost-reflect-derive"
version = "0.15.1"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab076798900edeaf1499ed1c30097db86e6697c5d02660a63d72fe4ebdcfefd2"
checksum = "7b6d90e29fa6c0d13c2c19ba5e4b3fb0efbf5975d27bcf4e260b7b15455bcabe"
dependencies = [
"proc-macro2",
"quote",
@@ -4618,11 +4629,11 @@ dependencies = [
[[package]]
name = "prost-types"
version = "0.13.5"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52c2c1bf36ddb1a1c396b3601a3cec27c2462e45f07c386894ec3ccf5332bd16"
checksum = "b9b4db3d6da204ed77bb26ba83b6122a73aeb2e87e25fbf7ad2e84c4ccbf8f72"
dependencies = [
"prost",
"prost 0.14.1",
]
[[package]]
@@ -5371,9 +5382,9 @@ dependencies = [
[[package]]
name = "schemars"
version = "1.0.2"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab5f657913eee4bddb062d3aa42193b9285e0e333f852885909a27d867579f2a"
checksum = "1375ba8ef45a6f15d83fa8748f1079428295d403d6ea991d09ab100155fbc06d"
dependencies = [
"dyn-clone",
"ref-cast",
@@ -5384,9 +5395,9 @@ dependencies = [
[[package]]
name = "schemars_derive"
version = "1.0.2"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d367383cbc8d37ce3aa513ca69daf21053d8e96c999fec305c2b402d790e66c"
checksum = "2b13ed22d6d49fe23712e068770b5c4df4a693a2b02eeff8e7ca3135627a24f6"
dependencies = [
"proc-macro2",
"quote",
@@ -5572,9 +5583,9 @@ dependencies = [
[[package]]
name = "serde_rusqlite"
version = "0.39.1"
version = "0.39.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4bc35a7ff183ff8a9f26143589c4631a98eec73b7d23a135a6f769231f50fa5"
checksum = "ab5457c3fa8a30df47786b725c1c96ecb7944f9c6f834eeec0ba29aa5fdc7e47"
dependencies = [
"rusqlite",
"serde",
@@ -6511,17 +6522,19 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tokio"
version = "1.45.1"
version = "1.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75ef51a33ef1da925cea3e4eb122833cb377c61439ca401b770f54902b806779"
checksum = "1140bb80481756a8cbe10541f37433b459c5aa1e727b4c020fbfebdc25bf3ec4"
dependencies = [
"backtrace",
"bytes",
"io-uring",
"libc",
"mio",
"parking_lot",
"pin-project-lite",
"signal-hook-registry",
"slab",
"socket2",
"tokio-macros",
"windows-sys 0.52.0",
@@ -6614,7 +6627,7 @@ dependencies = [
"hyper-util",
"percent-encoding",
"pin-project",
"prost",
"prost 0.13.5",
"socket2",
"tokio",
"tokio-stream",
@@ -6795,7 +6808,6 @@ dependencies = [
"async-trait",
"axum 0.8.4",
"axum-client-ip",
"axum-extra",
"axum-test",
"base64 0.22.1",
"bytes",
@@ -6807,6 +6819,7 @@ dependencies = [
"fallible-iterator",
"form_urlencoded",
"futures-util",
"http-body-util",
"hyper",
"hyper-util",
"indoc",
@@ -6823,7 +6836,7 @@ dependencies = [
"object_store",
"parking_lot",
"pin-project-lite",
"prost",
"prost 0.14.1",
"prost-reflect",
"quoted_printable",
"rand 0.9.1",

View File

@@ -11,5 +11,5 @@ readme = "../README.md"
[dependencies]
env_logger = { workspace = true }
log = "0.4.27"
prost-build = "^0.13.4"
prost-reflect-build = "0.15.0"
prost-build = "^0.14.1"
prost-reflect-build = "0.16.0"

View File

@@ -32,7 +32,6 @@ async-channel = "2.3.1"
async-trait = "0.1.80"
axum = { workspace = true }
axum-client-ip = "0.7.0"
axum-extra = { version = "^0.10.0", default-features = false, features = ["protobuf"] }
base64 = { version = "0.22.1", default-features = false, features = ["alloc"] }
bytes = { version = "1.8.0", features = ["serde"] }
chrono = "^0.4.38"
@@ -41,6 +40,7 @@ ed25519-dalek = { version = "2.1.1", features = ["pkcs8", "pem", "rand_core"] }
fallible-iterator = "0.3.0"
form_urlencoded = "1.2.1"
futures-util = { version = "0.3", default-features = false, features = ["alloc"] }
http-body-util = "0.1.3"
hyper = "1.6.0"
hyper-util = "0.1.7"
indoc = "2.0.5"
@@ -57,8 +57,8 @@ oauth2 = { version = "5.0.0-alpha.4", default-features = false, features = ["req
object_store = { version = "0.12.0", default-features = false, features = ["aws", "fs"] }
parking_lot = { version = "0.12.3", default-features = false }
pin-project-lite = "0.2.16"
prost = { version = "^0.13.4", default-features = false }
prost-reflect = { version = "^0.15.0", default-features = false, features = ["derive", "text-format"] }
prost = { version = "^0.14.1", default-features = false }
prost-reflect = { version = "^0.16.0", default-features = false, features = ["derive", "text-format"] }
rand = "^0.9.0"
regex = "1.11.0"
reqwest = { version = "0.12.8", default-features = false, features = ["rustls-tls", "json"] }

View File

@@ -1,5 +1,4 @@
use axum::extract::State;
use axum_extra::protobuf::Protobuf;
use crate::admin::AdminError as Error;
use crate::app_state::AppState;
@@ -7,6 +6,7 @@ use crate::config::{
proto::{GetConfigResponse, hash_config},
redact_secrets,
};
use crate::extract::protobuf::Protobuf;
pub async fn get_config_handler(
State(state): State<AppState>,

View File

@@ -1,12 +1,12 @@
use axum::extract::State;
use axum::http::StatusCode;
use axum::response::IntoResponse;
use axum_extra::protobuf::Protobuf;
use crate::admin::AdminError as Error;
use crate::app_state::AppState;
use crate::config::proto::{UpdateConfigRequest, Vault};
use crate::config::{merge_vault_and_env, redact_secrets};
use crate::extract::protobuf::Protobuf;
pub async fn update_config_handler(
State(state): State<AppState>,

View File

@@ -1,4 +1,5 @@
mod either;
mod multipart;
pub mod protobuf;
pub use either::Either;

View File

@@ -0,0 +1,92 @@
//! Protocol Buffer extractor and response.
//!
//! From https://github.com/tokio-rs/axum/blob/main/axum-extra/src/protobuf.rs. Pulled out to update prost.
use axum::http::StatusCode;
use axum::{
RequestExt,
extract::{FromRequest, Request},
response::{IntoResponse, Response},
};
use bytes::BytesMut;
use http_body_util::BodyExt;
use prost::Message;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum ProtobufRejection {
#[error("ProtobufDecode")]
ProtobufDecodeError,
}
impl IntoResponse for ProtobufRejection {
fn into_response(self) -> Response {
match self {
ProtobufRejection::ProtobufDecodeError => {
(StatusCode::UNPROCESSABLE_ENTITY, "invalid input").into_response()
}
}
}
}
/// A Protocol Buffer message extractor and response.
///
/// This can be used both as an extractor and as a response.
///
/// # As extractor
///
/// When used as an extractor, it can decode request bodies into some type that
/// implements [`prost::Message`]. The request will be rejected (and a [`ProtobufRejection`] will
/// be returned) if:
///
/// - The body couldn't be decoded into the target Protocol Buffer message type.
/// - Buffering the request body fails.
///
/// See [`ProtobufRejection`] for more details.
#[derive(Debug, Clone, Copy, Default)]
#[cfg_attr(docsrs, doc(cfg(feature = "protobuf")))]
#[must_use]
pub struct Protobuf<T>(pub T);
impl<T, S> FromRequest<S> for Protobuf<T>
where
T: Message + Default,
S: Send + Sync,
{
type Rejection = ProtobufRejection;
async fn from_request(req: Request, _: &S) -> Result<Self, Self::Rejection> {
let mut buf = req
.into_limited_body()
.collect()
.await
.map_err(|_| ProtobufRejection::ProtobufDecodeError)?
.aggregate();
match T::decode(&mut buf) {
Ok(value) => Ok(Protobuf(value)),
Err(_err) => Err(ProtobufRejection::ProtobufDecodeError),
}
}
}
// __impl_deref!(Protobuf);
impl<T> From<T> for Protobuf<T> {
fn from(inner: T) -> Self {
Self(inner)
}
}
impl<T> IntoResponse for Protobuf<T>
where
T: Message + Default,
{
fn into_response(self) -> Response {
let mut buf = BytesMut::with_capacity(self.0.encoded_len());
match &self.0.encode(&mut buf) {
Ok(()) => buf.into_response(),
Err(err) => (StatusCode::INTERNAL_SERVER_ERROR, err.to_string()).into_response(),
}
}
}