mirror of
				https://github.com/meilisearch/meilisearch.git
				synced 2025-10-30 23:46:28 +00:00 
			
		
		
		
	Merge #2101
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:
		| @@ -11,7 +11,7 @@ name = "meilisearch" | ||||
| path = "src/main.rs" | ||||
|  | ||||
| [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 } | ||||
| cargo_toml = { version = "0.9", 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 } | ||||
|  | ||||
| [dependencies] | ||||
| actix-cors = { git = "https://github.com/MarinPostma/actix-extras.git", rev = "963ac94d" } | ||||
| actix-web = { version = "4.0.0-beta.9", features = ["rustls"] } | ||||
| actix-web-static-files = { git = "https://github.com/MarinPostma/actix-web-static-files.git", rev = "39d8006", optional = true } | ||||
| # TODO: specifying this dependency so semver doesn't bump to next beta | ||||
| actix-tls = "=3.0.0-beta.5" | ||||
| actix-cors = "0.6.0-beta.8" | ||||
| actix-web = { version = "4.0.0-beta.21", features = ["rustls"] } | ||||
| actix-web-static-files = { git = "https://github.com/robjtede/actix-web-static-files.git", rev = "ed74153", optional = true } | ||||
| anyhow = { version = "1.0.43", features = ["backtrace"] } | ||||
| arc-swap = "1.3.2" | ||||
| async-stream = "0.3.2" | ||||
| @@ -60,13 +58,15 @@ platform-dirs = "0.3.0" | ||||
| rand = "0.8.4" | ||||
| rayon = "1.5.1" | ||||
| regex = "1.5.4" | ||||
| rustls = "0.19.1" | ||||
| rustls = "0.20.2" | ||||
| rustls-pemfile = "0.2" | ||||
| segment = { version = "0.1.2", optional = true } | ||||
| serde = { version = "1.0.130", features = ["derive"] } | ||||
| serde_json = { version = "1.0.67", features = ["preserve_order"] } | ||||
| sha2 = "0.9.6" | ||||
| siphasher = "0.3.7" | ||||
| slice-group-by = "0.2.6" | ||||
| static-files = { version = "0.2.1", optional = true } | ||||
| clap = { version = "3.0", features = ["derive", "env"] } | ||||
| sysinfo = "0.20.2" | ||||
| tar = "0.4.37" | ||||
| @@ -88,6 +88,7 @@ urlencoding = "2.1.0" | ||||
| [features] | ||||
| mini-dashboard = [ | ||||
|     "actix-web-static-files", | ||||
|     "static-files", | ||||
|     "anyhow", | ||||
|     "cargo_toml", | ||||
|     "hex", | ||||
|   | ||||
| @@ -16,11 +16,11 @@ mod mini_dashboard { | ||||
|     use std::io::{Cursor, Read, Write}; | ||||
|     use std::path::PathBuf; | ||||
|  | ||||
|     use actix_web_static_files::resource_dir; | ||||
|     use anyhow::Context; | ||||
|     use cargo_toml::Manifest; | ||||
|     use reqwest::blocking::get; | ||||
|     use sha1::{Digest, Sha1}; | ||||
|     use static_files::resource_dir; | ||||
|  | ||||
|     pub fn setup_mini_dashboard() -> anyhow::Result<()> { | ||||
|         let cargo_manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); | ||||
|   | ||||
| @@ -32,8 +32,6 @@ impl<T, D> Deref for GuardedData<T, D> { | ||||
| } | ||||
|  | ||||
| impl<P: Policy + 'static, D: 'static + Clone> FromRequest for GuardedData<P, D> { | ||||
|     type Config = (); | ||||
|  | ||||
|     type Error = ResponseError; | ||||
|  | ||||
|     type Future = Ready<Result<Self, Self::Error>>; | ||||
|   | ||||
| @@ -28,8 +28,6 @@ impl Default for PayloadConfig { | ||||
| } | ||||
|  | ||||
| impl FromRequest for Payload { | ||||
|     type Config = PayloadConfig; | ||||
|  | ||||
|     type Error = PayloadError; | ||||
|  | ||||
|     type Future = Ready<Result<Payload, Self::Error>>; | ||||
| @@ -39,7 +37,7 @@ impl FromRequest for Payload { | ||||
|         let limit = req | ||||
|             .app_data::<PayloadConfig>() | ||||
|             .map(|c| c.limit) | ||||
|             .unwrap_or(Self::Config::default().limit); | ||||
|             .unwrap_or(PayloadConfig::default().limit); | ||||
|         ready(Ok(Payload { | ||||
|             payload: payload.take(), | ||||
|             limit, | ||||
|   | ||||
| @@ -90,7 +90,7 @@ pub fn configure_data( | ||||
| #[cfg(feature = "mini-dashboard")] | ||||
| pub fn dashboard(config: &mut web::ServiceConfig, enable_frontend: bool) { | ||||
|     use actix_web::HttpResponse; | ||||
|     use actix_web_static_files::Resource; | ||||
|     use static_files::Resource; | ||||
|  | ||||
|     mod generated { | ||||
|         include!(concat!(env!("OUT_DIR"), "/generated.rs")); | ||||
|   | ||||
| @@ -6,11 +6,14 @@ use std::sync::Arc; | ||||
| use byte_unit::Byte; | ||||
| use clap::Parser; | ||||
| use meilisearch_lib::options::IndexerOpts; | ||||
| use rustls::internal::pemfile::{certs, pkcs8_private_keys, rsa_private_keys}; | ||||
| use rustls::{ | ||||
|     AllowAnyAnonymousOrAuthenticatedClient, AllowAnyAuthenticatedClient, NoClientAuth, | ||||
|     server::{ | ||||
|         AllowAnyAnonymousOrAuthenticatedClient, AllowAnyAuthenticatedClient, | ||||
|         ServerSessionMemoryCache, | ||||
|     }, | ||||
|     RootCertStore, | ||||
| }; | ||||
| use rustls_pemfile::{certs, pkcs8_private_keys, rsa_private_keys}; | ||||
|  | ||||
| const POSSIBLE_ENV: [&str; 2] = ["development", "production"]; | ||||
|  | ||||
| @@ -131,7 +134,9 @@ pub struct Opt { | ||||
| impl Opt { | ||||
|     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) { | ||||
|             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) => { | ||||
|                     let roots = load_certs(auth_path.to_path_buf())?; | ||||
|                     let mut client_auth_roots = RootCertStore::empty(); | ||||
| @@ -139,30 +144,32 @@ impl Opt { | ||||
|                         client_auth_roots.add(&root).unwrap(); | ||||
|                     } | ||||
|                     if self.ssl_require_auth { | ||||
|                         AllowAnyAuthenticatedClient::new(client_auth_roots) | ||||
|                         let verifier = AllowAnyAuthenticatedClient::new(client_auth_roots); | ||||
|                         config.with_client_cert_verifier(verifier) | ||||
|                     } 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 privkey = load_private_key(key_path.to_path_buf())?; | ||||
|             let ocsp = load_ocsp(&self.ssl_ocsp_path)?; | ||||
|             config | ||||
|                 .set_single_cert_with_ocsp_and_sct(certs, privkey, ocsp, vec![]) | ||||
|             let mut config = config | ||||
|                 .with_single_cert_with_ocsp_and_sct(certs, privkey, ocsp, vec![]) | ||||
|                 .map_err(|_| anyhow::anyhow!("bad certificates/private key"))?; | ||||
|  | ||||
|             config.key_log = Arc::new(rustls::KeyLogFile::new()); | ||||
|  | ||||
|             if self.ssl_resumption { | ||||
|                 config.set_persistence(rustls::ServerSessionMemoryCache::new(256)); | ||||
|                 config.session_storage = ServerSessionMemoryCache::new(256); | ||||
|             } | ||||
|  | ||||
|             if self.ssl_tickets { | ||||
|                 config.ticketer = rustls::Ticketer::new(); | ||||
|                 config.ticketer = rustls::Ticketer::new().unwrap(); | ||||
|             } | ||||
|  | ||||
|             Ok(Some(config)) | ||||
| @@ -176,7 +183,9 @@ fn load_certs(filename: PathBuf) -> anyhow::Result<Vec<rustls::Certificate>> { | ||||
|     let certfile = | ||||
|         fs::File::open(filename).map_err(|_| anyhow::anyhow!("cannot open certificate file"))?; | ||||
|     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> { | ||||
| @@ -201,10 +210,10 @@ fn load_private_key(filename: PathBuf) -> anyhow::Result<rustls::PrivateKey> { | ||||
|  | ||||
|     // prefer to load pkcs8 keys | ||||
|     if !pkcs8_keys.is_empty() { | ||||
|         Ok(pkcs8_keys[0].clone()) | ||||
|         Ok(rustls::PrivateKey(pkcs8_keys[0].clone())) | ||||
|     } else { | ||||
|         assert!(!rsa_keys.is_empty()); | ||||
|         Ok(rsa_keys[0].clone()) | ||||
|         Ok(rustls::PrivateKey(rsa_keys[0].clone())) | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user