2101: chore(all): update actix-web dependency to 4.0.0-beta.21 r=MarinPostma a=robjtede

# Pull Request

## What does this PR do?
I don't expect any more breaking changes to Actix Web that will affect Meilisearch so bump to latest beta.

Fixes #N/A?
<!-- Please link the issue you're trying to fix with this PR, if none then please create an issue first. -->

## PR checklist
Please check if your PR fulfills the following requirements:
- [ ] Does this PR fix an existing issue?
- [x] Have you read the contributing guidelines?
- [x] Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to MeiliSearch!


Co-authored-by: Rob Ede <robjtede@icloud.com>
This commit is contained in:
bors[bot] 2022-01-24 14:33:46 +00:00 committed by GitHub
commit 8ae504bfb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 511 additions and 505 deletions

939
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -5,8 +5,7 @@ authors = ["marin <postma.marin@protonmail.com>"]
edition = "2021" edition = "2021"
[dependencies] [dependencies]
actix-http = "=3.0.0-beta.10" actix-web = { version = "4.0.0-beta.21", default-features = false }
actix-web = "4.0.0-beta.9"
proptest = { version = "1.0.0", optional = true } proptest = { version = "1.0.0", optional = true }
proptest-derive = { version = "0.3.0", optional = true } proptest-derive = { version = "0.3.0", optional = true }
serde = { version = "1.0.130", features = ["derive"] } serde = { version = "1.0.130", features = ["derive"] }

View File

@ -1,7 +1,6 @@
use std::fmt; use std::fmt;
use actix_http::{body::Body, http::StatusCode}; use actix_web::{self as aweb, http::StatusCode, HttpResponseBuilder};
use actix_web::{self as aweb, HttpResponseBuilder};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
@ -59,7 +58,7 @@ where
} }
impl aweb::error::ResponseError for ResponseError { impl aweb::error::ResponseError for ResponseError {
fn error_response(&self) -> aweb::HttpResponse<Body> { fn error_response(&self) -> aweb::HttpResponse {
let json = serde_json::to_vec(self).unwrap(); let json = serde_json::to_vec(self).unwrap();
HttpResponseBuilder::new(self.status_code()) HttpResponseBuilder::new(self.status_code())
.content_type("application/json") .content_type("application/json")

View File

@ -11,7 +11,7 @@ name = "meilisearch"
path = "src/main.rs" path = "src/main.rs"
[build-dependencies] [build-dependencies]
actix-web-static-files = { git = "https://github.com/MarinPostma/actix-web-static-files.git", rev = "39d8006", optional = true } static-files = { version = "0.2.1", optional = true }
anyhow = { version = "1.0.43", optional = true } anyhow = { version = "1.0.43", optional = true }
cargo_toml = { version = "0.9", optional = true } cargo_toml = { version = "0.9", optional = true }
hex = { version = "0.4.3", optional = true } hex = { version = "0.4.3", optional = true }
@ -22,11 +22,9 @@ vergen = { version = "5.1.15", default-features = false, features = ["git"] }
zip = { version = "0.5.13", optional = true } zip = { version = "0.5.13", optional = true }
[dependencies] [dependencies]
actix-cors = { git = "https://github.com/MarinPostma/actix-extras.git", rev = "963ac94d" } actix-cors = "0.6.0-beta.8"
actix-web = { version = "4.0.0-beta.9", features = ["rustls"] } actix-web = { version = "4.0.0-beta.21", features = ["rustls"] }
actix-web-static-files = { git = "https://github.com/MarinPostma/actix-web-static-files.git", rev = "39d8006", optional = true } actix-web-static-files = { git = "https://github.com/robjtede/actix-web-static-files.git", rev = "ed74153", optional = true }
# TODO: specifying this dependency so semver doesn't bump to next beta
actix-tls = "=3.0.0-beta.5"
anyhow = { version = "1.0.43", features = ["backtrace"] } anyhow = { version = "1.0.43", features = ["backtrace"] }
arc-swap = "1.3.2" arc-swap = "1.3.2"
async-stream = "0.3.2" async-stream = "0.3.2"
@ -60,13 +58,15 @@ platform-dirs = "0.3.0"
rand = "0.8.4" rand = "0.8.4"
rayon = "1.5.1" rayon = "1.5.1"
regex = "1.5.4" regex = "1.5.4"
rustls = "0.19.1" rustls = "0.20.2"
rustls-pemfile = "0.2"
segment = { version = "0.1.2", optional = true } segment = { version = "0.1.2", optional = true }
serde = { version = "1.0.130", features = ["derive"] } serde = { version = "1.0.130", features = ["derive"] }
serde_json = { version = "1.0.67", features = ["preserve_order"] } serde_json = { version = "1.0.67", features = ["preserve_order"] }
sha2 = "0.9.6" sha2 = "0.9.6"
siphasher = "0.3.7" siphasher = "0.3.7"
slice-group-by = "0.2.6" slice-group-by = "0.2.6"
static-files = { version = "0.2.1", optional = true }
clap = { version = "3.0", features = ["derive", "env"] } clap = { version = "3.0", features = ["derive", "env"] }
sysinfo = "0.20.2" sysinfo = "0.20.2"
tar = "0.4.37" tar = "0.4.37"
@ -88,6 +88,7 @@ urlencoding = "2.1.0"
[features] [features]
mini-dashboard = [ mini-dashboard = [
"actix-web-static-files", "actix-web-static-files",
"static-files",
"anyhow", "anyhow",
"cargo_toml", "cargo_toml",
"hex", "hex",

View File

@ -16,11 +16,11 @@ mod mini_dashboard {
use std::io::{Cursor, Read, Write}; use std::io::{Cursor, Read, Write};
use std::path::PathBuf; use std::path::PathBuf;
use actix_web_static_files::resource_dir;
use anyhow::Context; use anyhow::Context;
use cargo_toml::Manifest; use cargo_toml::Manifest;
use reqwest::blocking::get; use reqwest::blocking::get;
use sha1::{Digest, Sha1}; use sha1::{Digest, Sha1};
use static_files::resource_dir;
pub fn setup_mini_dashboard() -> anyhow::Result<()> { pub fn setup_mini_dashboard() -> anyhow::Result<()> {
let cargo_manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); let cargo_manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());

View File

@ -32,8 +32,6 @@ impl<T, D> Deref for GuardedData<T, D> {
} }
impl<P: Policy + 'static, D: 'static + Clone> FromRequest for GuardedData<P, D> { impl<P: Policy + 'static, D: 'static + Clone> FromRequest for GuardedData<P, D> {
type Config = ();
type Error = ResponseError; type Error = ResponseError;
type Future = Ready<Result<Self, Self::Error>>; type Future = Ready<Result<Self, Self::Error>>;

View File

@ -28,8 +28,6 @@ impl Default for PayloadConfig {
} }
impl FromRequest for Payload { impl FromRequest for Payload {
type Config = PayloadConfig;
type Error = PayloadError; type Error = PayloadError;
type Future = Ready<Result<Payload, Self::Error>>; type Future = Ready<Result<Payload, Self::Error>>;
@ -39,7 +37,7 @@ impl FromRequest for Payload {
let limit = req let limit = req
.app_data::<PayloadConfig>() .app_data::<PayloadConfig>()
.map(|c| c.limit) .map(|c| c.limit)
.unwrap_or(Self::Config::default().limit); .unwrap_or(PayloadConfig::default().limit);
ready(Ok(Payload { ready(Ok(Payload {
payload: payload.take(), payload: payload.take(),
limit, limit,

View File

@ -90,7 +90,7 @@ pub fn configure_data(
#[cfg(feature = "mini-dashboard")] #[cfg(feature = "mini-dashboard")]
pub fn dashboard(config: &mut web::ServiceConfig, enable_frontend: bool) { pub fn dashboard(config: &mut web::ServiceConfig, enable_frontend: bool) {
use actix_web::HttpResponse; use actix_web::HttpResponse;
use actix_web_static_files::Resource; use static_files::Resource;
mod generated { mod generated {
include!(concat!(env!("OUT_DIR"), "/generated.rs")); include!(concat!(env!("OUT_DIR"), "/generated.rs"));

View File

@ -6,11 +6,14 @@ use std::sync::Arc;
use byte_unit::Byte; use byte_unit::Byte;
use clap::Parser; use clap::Parser;
use meilisearch_lib::options::IndexerOpts; use meilisearch_lib::options::IndexerOpts;
use rustls::internal::pemfile::{certs, pkcs8_private_keys, rsa_private_keys};
use rustls::{ use rustls::{
AllowAnyAnonymousOrAuthenticatedClient, AllowAnyAuthenticatedClient, NoClientAuth, server::{
AllowAnyAnonymousOrAuthenticatedClient, AllowAnyAuthenticatedClient,
ServerSessionMemoryCache,
},
RootCertStore, RootCertStore,
}; };
use rustls_pemfile::{certs, pkcs8_private_keys, rsa_private_keys};
const POSSIBLE_ENV: [&str; 2] = ["development", "production"]; const POSSIBLE_ENV: [&str; 2] = ["development", "production"];
@ -131,7 +134,9 @@ pub struct Opt {
impl Opt { impl Opt {
pub fn get_ssl_config(&self) -> anyhow::Result<Option<rustls::ServerConfig>> { pub fn get_ssl_config(&self) -> anyhow::Result<Option<rustls::ServerConfig>> {
if let (Some(cert_path), Some(key_path)) = (&self.ssl_cert_path, &self.ssl_key_path) { if let (Some(cert_path), Some(key_path)) = (&self.ssl_cert_path, &self.ssl_key_path) {
let client_auth = match &self.ssl_auth_path { let config = rustls::ServerConfig::builder().with_safe_defaults();
let config = match &self.ssl_auth_path {
Some(auth_path) => { Some(auth_path) => {
let roots = load_certs(auth_path.to_path_buf())?; let roots = load_certs(auth_path.to_path_buf())?;
let mut client_auth_roots = RootCertStore::empty(); let mut client_auth_roots = RootCertStore::empty();
@ -139,30 +144,32 @@ impl Opt {
client_auth_roots.add(&root).unwrap(); client_auth_roots.add(&root).unwrap();
} }
if self.ssl_require_auth { if self.ssl_require_auth {
AllowAnyAuthenticatedClient::new(client_auth_roots) let verifier = AllowAnyAuthenticatedClient::new(client_auth_roots);
config.with_client_cert_verifier(verifier)
} else { } else {
AllowAnyAnonymousOrAuthenticatedClient::new(client_auth_roots) let verifier =
AllowAnyAnonymousOrAuthenticatedClient::new(client_auth_roots);
config.with_client_cert_verifier(verifier)
} }
} }
None => NoClientAuth::new(), None => config.with_no_client_auth(),
}; };
let mut config = rustls::ServerConfig::new(client_auth);
config.key_log = Arc::new(rustls::KeyLogFile::new());
let certs = load_certs(cert_path.to_path_buf())?; let certs = load_certs(cert_path.to_path_buf())?;
let privkey = load_private_key(key_path.to_path_buf())?; let privkey = load_private_key(key_path.to_path_buf())?;
let ocsp = load_ocsp(&self.ssl_ocsp_path)?; let ocsp = load_ocsp(&self.ssl_ocsp_path)?;
config let mut config = config
.set_single_cert_with_ocsp_and_sct(certs, privkey, ocsp, vec![]) .with_single_cert_with_ocsp_and_sct(certs, privkey, ocsp, vec![])
.map_err(|_| anyhow::anyhow!("bad certificates/private key"))?; .map_err(|_| anyhow::anyhow!("bad certificates/private key"))?;
config.key_log = Arc::new(rustls::KeyLogFile::new());
if self.ssl_resumption { if self.ssl_resumption {
config.set_persistence(rustls::ServerSessionMemoryCache::new(256)); config.session_storage = ServerSessionMemoryCache::new(256);
} }
if self.ssl_tickets { if self.ssl_tickets {
config.ticketer = rustls::Ticketer::new(); config.ticketer = rustls::Ticketer::new().unwrap();
} }
Ok(Some(config)) Ok(Some(config))
@ -176,7 +183,9 @@ fn load_certs(filename: PathBuf) -> anyhow::Result<Vec<rustls::Certificate>> {
let certfile = let certfile =
fs::File::open(filename).map_err(|_| anyhow::anyhow!("cannot open certificate file"))?; fs::File::open(filename).map_err(|_| anyhow::anyhow!("cannot open certificate file"))?;
let mut reader = BufReader::new(certfile); let mut reader = BufReader::new(certfile);
certs(&mut reader).map_err(|_| anyhow::anyhow!("cannot read certificate file")) certs(&mut reader)
.map(|certs| certs.into_iter().map(rustls::Certificate).collect())
.map_err(|_| anyhow::anyhow!("cannot read certificate file"))
} }
fn load_private_key(filename: PathBuf) -> anyhow::Result<rustls::PrivateKey> { fn load_private_key(filename: PathBuf) -> anyhow::Result<rustls::PrivateKey> {
@ -201,10 +210,10 @@ fn load_private_key(filename: PathBuf) -> anyhow::Result<rustls::PrivateKey> {
// prefer to load pkcs8 keys // prefer to load pkcs8 keys
if !pkcs8_keys.is_empty() { if !pkcs8_keys.is_empty() {
Ok(pkcs8_keys[0].clone()) Ok(rustls::PrivateKey(pkcs8_keys[0].clone()))
} else { } else {
assert!(!rsa_keys.is_empty()); assert!(!rsa_keys.is_empty());
Ok(rsa_keys[0].clone()) Ok(rustls::PrivateKey(rsa_keys[0].clone()))
} }
} }

View File

@ -6,8 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
actix-web = { version = "4.0.0-beta.9", features = ["rustls"] } actix-web = { version = "4.0.0-beta.21", default-features = false }
actix-web-static-files = { git = "https://github.com/MarinPostma/actix-web-static-files.git", rev = "39d8006", optional = true }
anyhow = { version = "1.0.43", features = ["backtrace"] } anyhow = { version = "1.0.43", features = ["backtrace"] }
async-stream = "0.3.2" async-stream = "0.3.2"
async-trait = "0.1.51" async-trait = "0.1.51"