From 371baa86a42c7871830d92f49acb980e6b95e80f Mon Sep 17 00:00:00 2001 From: Sunli Date: Sat, 30 Mar 2024 11:45:55 +0800 Subject: [PATCH] poem `3.0.0` --- Cargo.toml | 10 ++-- .../auth-github/Cargo.toml | 0 .../auth-github/src/main.rs | 0 poem-derive/Cargo.toml | 2 +- poem-grpc-build/Cargo.toml | 2 +- poem-grpc/Cargo.toml | 4 +- poem-lambda/CHANGELOG.md | 2 +- poem-lambda/Cargo.toml | 4 +- poem-openapi-derive/Cargo.toml | 2 +- poem-openapi/CHANGELOG.md | 2 +- poem-openapi/Cargo.toml | 2 +- poem/CHANGELOG.md | 17 +++--- poem/Cargo.toml | 6 +- poem/src/listener/acme/listener.rs | 58 ++++++++----------- 14 files changed, 52 insertions(+), 59 deletions(-) rename examples/{disabled => openapi}/auth-github/Cargo.toml (100%) rename examples/{disabled => openapi}/auth-github/src/main.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 0fe5324bfc..6419e75267 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,10 +20,10 @@ repository = "https://github.com/poem-web/poem" rust-version = "1.75" [workspace.dependencies] -poem = { path = "poem", version = "2.0.1", default-features = false } -poem-derive = { path = "poem-derive", version = "2.0.1" } -poem-openapi-derive = { path = "poem-openapi-derive", version = "4.0.1" } -poem-grpc-build = { path = "poem-grpc-build", version = "0.3.0" } +poem = { path = "poem", version = "3.0.0", default-features = false } +poem-derive = { path = "poem-derive", version = "3.0.0" } +poem-openapi-derive = { path = "poem-openapi-derive", version = "5.0.0" } +poem-grpc-build = { path = "poem-grpc-build", version = "0.4.0" } proc-macro-crate = "3.0.0" proc-macro2 = "1.0.29" @@ -42,7 +42,7 @@ futures-util = "0.3.17" tokio-stream = "0.1.8" serde_yaml = "0.9" quick-xml = { version = "0.31.0", features = ["serialize"] } -base64 = "0.21.0" +base64 = "0.22.0" serde_urlencoded = "0.7.1" indexmap = "2.0.0" reqwest = { version = "0.12.2", default-features = false } diff --git a/examples/disabled/auth-github/Cargo.toml b/examples/openapi/auth-github/Cargo.toml similarity index 100% rename from examples/disabled/auth-github/Cargo.toml rename to examples/openapi/auth-github/Cargo.toml diff --git a/examples/disabled/auth-github/src/main.rs b/examples/openapi/auth-github/src/main.rs similarity index 100% rename from examples/disabled/auth-github/src/main.rs rename to examples/openapi/auth-github/src/main.rs diff --git a/poem-derive/Cargo.toml b/poem-derive/Cargo.toml index 63d46376f1..52ea6715db 100644 --- a/poem-derive/Cargo.toml +++ b/poem-derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "poem-derive" -version = "2.0.1" +version = "3.0.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/poem-grpc-build/Cargo.toml b/poem-grpc-build/Cargo.toml index c0f107a382..efb44e6054 100644 --- a/poem-grpc-build/Cargo.toml +++ b/poem-grpc-build/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "poem-grpc-build" -version = "0.3.0" +version = "0.4.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/poem-grpc/Cargo.toml b/poem-grpc/Cargo.toml index dab8b02c75..fe2a2dbf96 100644 --- a/poem-grpc/Cargo.toml +++ b/poem-grpc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "poem-grpc" -version = "0.3.0" +version = "0.4.0" authors.workspace = true edition.workspace = true license.workspace = true @@ -28,7 +28,7 @@ itoa = "1.0.2" percent-encoding = "2.1.0" bytes.workspace = true prost = "0.12.0" -base64 = "0.21.0" +base64.workspace = true prost-types = "0.12.0" tokio-stream = { workspace = true, features = ["sync"] } serde = { workspace = true, optional = true } diff --git a/poem-lambda/CHANGELOG.md b/poem-lambda/CHANGELOG.md index 71db916474..f9c612503b 100644 --- a/poem-lambda/CHANGELOG.md +++ b/poem-lambda/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -# [5.0.0] 2024-03-24 +# [5.0.0] 2024-03-30 - use AFIT instead of `async_trait` - Bump `lambda_http` from `0.9` to `0.10` diff --git a/poem-lambda/Cargo.toml b/poem-lambda/Cargo.toml index 777cc3ff08..2ea3f62aeb 100644 --- a/poem-lambda/Cargo.toml +++ b/poem-lambda/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "poem-lambda" -version = "4.0.0" +version = "5.0.0" authors.workspace = true edition.workspace = true license.workspace = true @@ -21,7 +21,7 @@ categories = [ [dependencies] poem = { workspace = true, default-features = false } -lambda_http = { version = "0.10.0" } +lambda_http = { version = "0.11.0" } [dev-dependencies] tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } diff --git a/poem-openapi-derive/Cargo.toml b/poem-openapi-derive/Cargo.toml index 96c7123c99..181345ef0b 100644 --- a/poem-openapi-derive/Cargo.toml +++ b/poem-openapi-derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "poem-openapi-derive" -version = "4.0.1" +version = "5.0.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/poem-openapi/CHANGELOG.md b/poem-openapi/CHANGELOG.md index 54503aebfc..bb65e1dd51 100644 --- a/poem-openapi/CHANGELOG.md +++ b/poem-openapi/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -# [5.0.0] 2024-03-24 +# [5.0.0] 2024-03-30 - use AFIT instead of `async_trait` - add `Upload::size` method diff --git a/poem-openapi/Cargo.toml b/poem-openapi/Cargo.toml index 6c35e78713..298a254b5e 100644 --- a/poem-openapi/Cargo.toml +++ b/poem-openapi/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "poem-openapi" -version = "4.0.1" +version = "5.0.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/poem/CHANGELOG.md b/poem/CHANGELOG.md index 2dd2a2dd23..b89263d240 100644 --- a/poem/CHANGELOG.md +++ b/poem/CHANGELOG.md @@ -4,15 +4,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -# [3.0.0] 2024-03-24 +# [3.0.0] 2024-03-30 - use AFIT instead of `async_trait` -- bump `priority-queue` to 2.0 -- bump `x509-parser` to 0.16 -- bump `nix` to 0.28 -- bump `redis` to 0.25 -- bump `reqwest` to 0.12 -- bump `opentelemetry` to 0.22 [#784](https://github.com/poem-web/poem/pull/784) +- bump `priority-queue` to `2.0` +- bump `x509-parser` to `0.16` +- bump `nix` to `0.28` +- bump `redis` to `0.25` +- bump `reqwest` to `0.12` +- bump `opentelemetry` to `0.22` [#784](https://github.com/poem-web/poem/pull/784) +- bump `sync_wrapper` to `1.0.0` +- bump `rcgen ` to `0.13.0` +- bump `base64 ` to `0.22.0` # [2.0.1] 2024-03-04 diff --git a/poem/Cargo.toml b/poem/Cargo.toml index 75b4dfd484..591a862b47 100644 --- a/poem/Cargo.toml +++ b/poem/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "poem" -version = "2.0.1" +version = "3.0.0" authors.workspace = true edition.workspace = true license.workspace = true @@ -92,7 +92,7 @@ thiserror.workspace = true rfc7239 = "0.1.0" mime.workspace = true wildmatch = "2" -sync_wrapper = { version = "0.1.2", features = ["futures"] } +sync_wrapper = { version = "1.0.0", features = ["futures"] } # Non-feature optional dependencies multer = { version = "3.0.0", features = ["tokio"], optional = true } @@ -150,7 +150,7 @@ unic-langid = { version = "0.9.0", optional = true, features = ["macros"] } intl-memoizer = { version = "0.5.1", optional = true } ring = { version = "0.17.7", optional = true } reqwest = { workspace = true, features = ["json"], optional = true } -rcgen = { version = "0.12.0", optional = true } +rcgen = { version = "0.13.0", optional = true } x509-parser = { version = "0.16.0", optional = true } tokio-metrics = { version = "0.3.0", optional = true } rust-embed = { version = "8.0", optional = true } diff --git a/poem/src/listener/acme/listener.rs b/poem/src/listener/acme/listener.rs index 160b09ffe1..a9b36b195a 100644 --- a/poem/src/listener/acme/listener.rs +++ b/poem/src/listener/acme/listener.rs @@ -5,9 +5,7 @@ use std::{ }; use http::uri::Scheme; -use rcgen::{ - Certificate, CertificateParams, CustomExtension, DistinguishedName, PKCS_ECDSA_P256_SHA256, -}; +use rcgen::{CertificateParams, CustomExtension, KeyPair, PKCS_ECDSA_P256_SHA256}; use tokio_rustls::{ rustls::{ crypto::ring::sign::any_ecdsa_type, @@ -229,21 +227,21 @@ impl Acceptor for AutoCertAcceptor { } fn gen_acme_cert(domain: &str, acme_hash: &[u8]) -> IoResult { - let mut params = CertificateParams::new(vec![domain.to_string()]); - params.alg = &PKCS_ECDSA_P256_SHA256; - params.custom_extensions = vec![CustomExtension::new_acme_identifier(acme_hash)]; - let cert = Certificate::from_params(params) - .map_err(|_| IoError::new(ErrorKind::Other, "failed to generate acme certificate"))?; - let key = any_ecdsa_type(&PrivateKeyDer::Pkcs8( - cert.serialize_private_key_der().into(), - )) - .unwrap(); - Ok(CertifiedKey::new( - vec![CertificateDer::from(cert.serialize_der().map_err( - |_| IoError::new(ErrorKind::Other, "failed to serialize acme certificate"), - )?)], - key, - )) + let keypair = KeyPair::generate_for(&PKCS_ECDSA_P256_SHA256).expect("create key pair"); + let cert = CertificateParams::new(vec![domain.to_string()]) + .and_then(|mut params| { + params.custom_extensions = vec![CustomExtension::new_acme_identifier(acme_hash)]; + params.self_signed(&keypair) + }) + .map_err(|err| { + IoError::new( + ErrorKind::Other, + format!("failed to generate acme certificate: {err}"), + ) + })?; + + let key = any_ecdsa_type(&PrivateKeyDer::Pkcs8(keypair.serialized_der().into())).unwrap(); + Ok(CertifiedKey::new(vec![cert.der().clone()], key)) } /// The result of [`issue_cert`] function. @@ -343,31 +341,23 @@ pub async fn issue_cert>( } // send csr - let mut params = CertificateParams::new( + let keypair = KeyPair::generate_for(&PKCS_ECDSA_P256_SHA256).expect("create key pair"); + let request = CertificateParams::new( domains .iter() .map(|domain| domain.as_ref().to_string()) .collect::>(), - ); - params.distinguished_name = DistinguishedName::new(); - params.alg = &PKCS_ECDSA_P256_SHA256; - let cert = Certificate::from_params(params).map_err(|err| { + ) + .and_then(|params| params.serialize_request(&keypair)) + .map_err(|err| { IoError::new( ErrorKind::Other, format!("failed create certificate request: {err}"), ) })?; - let pk = any_ecdsa_type(&PrivateKeyDer::Pkcs8( - cert.serialize_private_key_der().into(), - )) - .unwrap(); - let csr = cert.serialize_request_der().map_err(|err| { - IoError::new( - ErrorKind::Other, - format!("failed to serialize request der {err}"), - ) - })?; + let pk = any_ecdsa_type(&PrivateKeyDer::Pkcs8(keypair.serialized_der().into())).unwrap(); + let csr = request.der().as_ref(); let order_resp = client.send_csr(&order_resp.finalize, &csr).await?; if order_resp.status == "invalid" { @@ -403,7 +393,7 @@ pub async fn issue_cert>( ) })?) .await?; - let pkey_pem = cert.serialize_private_key_pem(); + let pkey_pem = keypair.serialize_pem(); let cert_chain = rustls_pemfile::certs(&mut acme_cert_pem.as_slice()) .collect::>() .map_err(|err| IoError::new(ErrorKind::Other, format!("invalid pem: {err}")))?;