Merge pull request #174 from neon-mmd/patch-csrf-security-with-cors
Browse files- Cargo.lock +23 -7
- Cargo.toml +2 -1
- src/lib.rs +13 -1
Cargo.lock
CHANGED
@@ -19,6 +19,21 @@ dependencies = [
|
|
19 |
"tracing",
|
20 |
]
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
[[package]]
|
23 |
name = "actix-files"
|
24 |
version = "0.6.2"
|
@@ -190,7 +205,7 @@ dependencies = [
|
|
190 |
"serde_urlencoded 0.7.1",
|
191 |
"smallvec 1.11.0",
|
192 |
"socket2",
|
193 |
-
"time 0.3.
|
194 |
"url 2.4.0",
|
195 |
]
|
196 |
|
@@ -583,7 +598,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
583 |
checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb"
|
584 |
dependencies = [
|
585 |
"percent-encoding 2.3.0",
|
586 |
-
"time 0.3.
|
587 |
"version_check",
|
588 |
]
|
589 |
|
@@ -801,9 +816,9 @@ dependencies = [
|
|
801 |
|
802 |
[[package]]
|
803 |
name = "deranged"
|
804 |
-
version = "0.3.
|
805 |
source = "registry+https://github.com/rust-lang/crates.io-index"
|
806 |
-
checksum = "
|
807 |
|
808 |
[[package]]
|
809 |
name = "derive_more"
|
@@ -3000,9 +3015,9 @@ dependencies = [
|
|
3000 |
|
3001 |
[[package]]
|
3002 |
name = "time"
|
3003 |
-
version = "0.3.
|
3004 |
source = "registry+https://github.com/rust-lang/crates.io-index"
|
3005 |
-
checksum = "
|
3006 |
dependencies = [
|
3007 |
"deranged",
|
3008 |
"itoa 1.0.9",
|
@@ -3519,8 +3534,9 @@ dependencies = [
|
|
3519 |
|
3520 |
[[package]]
|
3521 |
name = "websurfx"
|
3522 |
-
version = "0.16.
|
3523 |
dependencies = [
|
|
|
3524 |
"actix-files",
|
3525 |
"actix-web",
|
3526 |
"async-trait",
|
|
|
19 |
"tracing",
|
20 |
]
|
21 |
|
22 |
+
[[package]]
|
23 |
+
name = "actix-cors"
|
24 |
+
version = "0.6.4"
|
25 |
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
26 |
+
checksum = "b340e9cfa5b08690aae90fb61beb44e9b06f44fe3d0f93781aaa58cfba86245e"
|
27 |
+
dependencies = [
|
28 |
+
"actix-utils",
|
29 |
+
"actix-web",
|
30 |
+
"derive_more",
|
31 |
+
"futures-util",
|
32 |
+
"log",
|
33 |
+
"once_cell",
|
34 |
+
"smallvec 1.11.0",
|
35 |
+
]
|
36 |
+
|
37 |
[[package]]
|
38 |
name = "actix-files"
|
39 |
version = "0.6.2"
|
|
|
205 |
"serde_urlencoded 0.7.1",
|
206 |
"smallvec 1.11.0",
|
207 |
"socket2",
|
208 |
+
"time 0.3.25",
|
209 |
"url 2.4.0",
|
210 |
]
|
211 |
|
|
|
598 |
checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb"
|
599 |
dependencies = [
|
600 |
"percent-encoding 2.3.0",
|
601 |
+
"time 0.3.25",
|
602 |
"version_check",
|
603 |
]
|
604 |
|
|
|
816 |
|
817 |
[[package]]
|
818 |
name = "deranged"
|
819 |
+
version = "0.3.7"
|
820 |
source = "registry+https://github.com/rust-lang/crates.io-index"
|
821 |
+
checksum = "7684a49fb1af197853ef7b2ee694bc1f5b4179556f1e5710e1760c5db6f5e929"
|
822 |
|
823 |
[[package]]
|
824 |
name = "derive_more"
|
|
|
3015 |
|
3016 |
[[package]]
|
3017 |
name = "time"
|
3018 |
+
version = "0.3.25"
|
3019 |
source = "registry+https://github.com/rust-lang/crates.io-index"
|
3020 |
+
checksum = "b0fdd63d58b18d663fbdf70e049f00a22c8e42be082203be7f26589213cd75ea"
|
3021 |
dependencies = [
|
3022 |
"deranged",
|
3023 |
"itoa 1.0.9",
|
|
|
3534 |
|
3535 |
[[package]]
|
3536 |
name = "websurfx"
|
3537 |
+
version = "0.16.1"
|
3538 |
dependencies = [
|
3539 |
+
"actix-cors",
|
3540 |
"actix-files",
|
3541 |
"actix-web",
|
3542 |
"async-trait",
|
Cargo.toml
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
[package]
|
2 |
name = "websurfx"
|
3 |
-
version = "0.16.
|
4 |
edition = "2021"
|
5 |
description = "An open-source alternative to Searx that provides clean, ad-free, and organic results with incredible speed while keeping privacy and security in mind."
|
6 |
repository = "https://github.com/neon-mmd/websurfx"
|
@@ -14,6 +14,7 @@ handlebars = { version = "4.3.6", features = ["dir_source"] }
|
|
14 |
scraper = {version="*"}
|
15 |
actix-web = {version="4.3.1", features = ["cookies"]}
|
16 |
actix-files = {version="0.6.2"}
|
|
|
17 |
serde_json = {version="*"}
|
18 |
fake-useragent = {version="*"}
|
19 |
env_logger = {version="0.10.0"}
|
|
|
1 |
[package]
|
2 |
name = "websurfx"
|
3 |
+
version = "0.16.1"
|
4 |
edition = "2021"
|
5 |
description = "An open-source alternative to Searx that provides clean, ad-free, and organic results with incredible speed while keeping privacy and security in mind."
|
6 |
repository = "https://github.com/neon-mmd/websurfx"
|
|
|
14 |
scraper = {version="*"}
|
15 |
actix-web = {version="4.3.1", features = ["cookies"]}
|
16 |
actix-files = {version="0.6.2"}
|
17 |
+
actix-cors = {version="0.6.4"}
|
18 |
serde_json = {version="*"}
|
19 |
fake-useragent = {version="*"}
|
20 |
env_logger = {version="0.10.0"}
|
src/lib.rs
CHANGED
@@ -12,8 +12,9 @@ use std::net::TcpListener;
|
|
12 |
|
13 |
use crate::server::routes;
|
14 |
|
|
|
15 |
use actix_files as fs;
|
16 |
-
use actix_web::{dev::Server, middleware::Logger, web, App, HttpServer};
|
17 |
use config::parser::Config;
|
18 |
use handlebars::Handlebars;
|
19 |
use handler::public_paths::public_path;
|
@@ -52,9 +53,20 @@ pub fn run(listener: TcpListener, config: Config) -> std::io::Result<Server> {
|
|
52 |
let cloned_config_threads_opt: u8 = config.threads;
|
53 |
|
54 |
let server = HttpServer::new(move || {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
App::new()
|
56 |
.app_data(handlebars_ref.clone())
|
57 |
.app_data(web::Data::new(config.clone()))
|
|
|
58 |
.wrap(Logger::default()) // added logging middleware for logging.
|
59 |
// Serve images and static files (css and js files).
|
60 |
.service(
|
|
|
12 |
|
13 |
use crate::server::routes;
|
14 |
|
15 |
+
use actix_cors::Cors;
|
16 |
use actix_files as fs;
|
17 |
+
use actix_web::{dev::Server, http::header, middleware::Logger, web, App, HttpServer};
|
18 |
use config::parser::Config;
|
19 |
use handlebars::Handlebars;
|
20 |
use handler::public_paths::public_path;
|
|
|
53 |
let cloned_config_threads_opt: u8 = config.threads;
|
54 |
|
55 |
let server = HttpServer::new(move || {
|
56 |
+
let cors: Cors = Cors::default()
|
57 |
+
.allow_any_origin()
|
58 |
+
.allowed_methods(vec!["GET"])
|
59 |
+
.allowed_headers(vec![
|
60 |
+
header::ORIGIN,
|
61 |
+
header::CONTENT_TYPE,
|
62 |
+
header::REFERER,
|
63 |
+
header::COOKIE,
|
64 |
+
]);
|
65 |
+
|
66 |
App::new()
|
67 |
.app_data(handlebars_ref.clone())
|
68 |
.app_data(web::Data::new(config.clone()))
|
69 |
+
.wrap(cors)
|
70 |
.wrap(Logger::default()) // added logging middleware for logging.
|
71 |
// Serve images and static files (css and js files).
|
72 |
.service(
|