Added native-tls for reqwest

This commit is contained in:
Joe Bellus 2022-02-12 08:03:27 +00:00
parent 31676b62b5
commit ffdc830e22
7 changed files with 115 additions and 210 deletions

View File

@ -12,8 +12,6 @@ test:
script: script:
- mkdir dist - mkdir dist
- touch dist/index.html - touch dist/index.html
- apt-get update
- apt-get -y install pkg-config
- cargo test - cargo test
build-ui: build-ui:
@ -40,8 +38,6 @@ build-x64-bin:
rules: rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script: script:
- apt-get update
- apt-get -y install libssl-dev pkg-config
- cargo build --release - cargo build --release
- cd target/release - cd target/release
- tar -czf ../../vade-linux-x64.tar.gz vade - tar -czf ../../vade-linux-x64.tar.gz vade

278
Cargo.lock generated
View File

@ -154,6 +154,7 @@ dependencies = [
"actix-codec 0.4.2", "actix-codec 0.4.2",
"actix-rt 2.6.0", "actix-rt 2.6.0",
"actix-service 2.0.2", "actix-service 2.0.2",
"actix-tls 3.0.2",
"actix-utils 3.0.0", "actix-utils 3.0.0",
"ahash", "ahash",
"base64", "base64",
@ -355,6 +356,24 @@ dependencies = [
"futures-util", "futures-util",
] ]
[[package]]
name = "actix-tls"
version = "3.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31ab31563b611fa822480b4255e8750cf0af9ce1b8b7bde298afe8447ef9333"
dependencies = [
"actix-codec 0.4.2",
"actix-rt 2.6.0",
"actix-service 2.0.2",
"actix-utils 3.0.0",
"futures-core",
"log",
"pin-project-lite 0.2.8",
"tokio-rustls 0.23.2",
"tokio-util 0.6.9",
"webpki-roots 0.22.2",
]
[[package]] [[package]]
name = "actix-utils" name = "actix-utils"
version = "2.0.0" version = "2.0.0"
@ -400,7 +419,7 @@ dependencies = [
"actix-service 1.0.6", "actix-service 1.0.6",
"actix-testing", "actix-testing",
"actix-threadpool", "actix-threadpool",
"actix-tls", "actix-tls 2.0.0",
"actix-utils 2.0.0", "actix-utils 2.0.0",
"actix-web-codegen 0.4.0", "actix-web-codegen 0.4.0",
"awc", "awc",
@ -437,6 +456,7 @@ dependencies = [
"actix-rt 2.6.0", "actix-rt 2.6.0",
"actix-server 2.0.0", "actix-server 2.0.0",
"actix-service 2.0.2", "actix-service 2.0.2",
"actix-tls 3.0.2",
"actix-utils 3.0.0", "actix-utils 3.0.0",
"actix-web-codegen 0.5.0-rc.2", "actix-web-codegen 0.5.0-rc.2",
"ahash", "ahash",
@ -871,22 +891,6 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2df960f5d869b2dd8532793fde43eb5427cceb126c929747a26823ab0eeb536" checksum = "a2df960f5d869b2dd8532793fde43eb5427cceb126c929747a26823ab0eeb536"
[[package]]
name = "core-foundation"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]]
name = "core-foundation-sys"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
[[package]] [[package]]
name = "cpufeatures" name = "cpufeatures"
version = "0.2.1" version = "0.2.1"
@ -1031,15 +1035,6 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "fastrand"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf"
dependencies = [
"instant",
]
[[package]] [[package]]
name = "firestorm" name = "firestorm"
version = "0.5.0" version = "0.5.0"
@ -1076,21 +1071,6 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "foreign-types"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
dependencies = [
"foreign-types-shared",
]
[[package]]
name = "foreign-types-shared"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]] [[package]]
name = "form_urlencoded" name = "form_urlencoded"
version = "1.0.1" version = "1.0.1"
@ -1415,16 +1395,16 @@ dependencies = [
] ]
[[package]] [[package]]
name = "hyper-tls" name = "hyper-rustls"
version = "0.5.0" version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" checksum = "d87c48c02e0dc5e3b849a2041db3029fd066650f8f717c07bf8ed78ccb895cac"
dependencies = [ dependencies = [
"bytes 1.1.0", "http",
"hyper", "hyper",
"native-tls", "rustls 0.20.2",
"tokio 1.16.1", "tokio 1.16.1",
"tokio-native-tls", "tokio-rustls 0.23.2",
] ]
[[package]] [[package]]
@ -1790,24 +1770,6 @@ dependencies = [
"winapi 0.3.9", "winapi 0.3.9",
] ]
[[package]]
name = "native-tls"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48ba9f7719b5a0f42f338907614285fb5fd70e53858141f69898a1fb7203b24d"
dependencies = [
"lazy_static",
"libc",
"log",
"openssl",
"openssl-probe",
"openssl-sys",
"schannel",
"security-framework",
"security-framework-sys",
"tempfile",
]
[[package]] [[package]]
name = "net2" name = "net2"
version = "0.2.37" version = "0.2.37"
@ -1911,39 +1873,6 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]]
name = "openssl"
version = "0.10.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c7ae222234c30df141154f159066c5093ff73b63204dcda7121eb082fc56a95"
dependencies = [
"bitflags",
"cfg-if 1.0.0",
"foreign-types",
"libc",
"once_cell",
"openssl-sys",
]
[[package]]
name = "openssl-probe"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-sys"
version = "0.9.72"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e46109c383602735fa0a2e48dd2b7c892b048e1bf69e5c3b1d804b7d9c203cb"
dependencies = [
"autocfg",
"cc",
"libc",
"pkg-config",
"vcpkg",
]
[[package]] [[package]]
name = "ouroboros" name = "ouroboros"
version = "0.14.0" version = "0.14.0"
@ -2263,15 +2192,6 @@ version = "0.6.25"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]]
name = "remove_dir_all"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
dependencies = [
"winapi 0.3.9",
]
[[package]] [[package]]
name = "reqwest" name = "reqwest"
version = "0.11.9" version = "0.11.9"
@ -2287,24 +2207,26 @@ dependencies = [
"http", "http",
"http-body", "http-body",
"hyper", "hyper",
"hyper-tls", "hyper-rustls",
"ipnet", "ipnet",
"js-sys", "js-sys",
"lazy_static", "lazy_static",
"log", "log",
"mime", "mime",
"native-tls",
"percent-encoding", "percent-encoding",
"pin-project-lite 0.2.8", "pin-project-lite 0.2.8",
"rustls 0.20.2",
"rustls-pemfile",
"serde", "serde",
"serde_json", "serde_json",
"serde_urlencoded", "serde_urlencoded",
"tokio 1.16.1", "tokio 1.16.1",
"tokio-native-tls", "tokio-rustls 0.23.2",
"url", "url",
"wasm-bindgen", "wasm-bindgen",
"wasm-bindgen-futures", "wasm-bindgen-futures",
"web-sys", "web-sys",
"webpki-roots 0.22.2",
"winreg 0.7.0", "winreg 0.7.0",
] ]
@ -2406,8 +2328,29 @@ dependencies = [
"base64", "base64",
"log", "log",
"ring", "ring",
"sct", "sct 0.6.1",
"webpki", "webpki 0.21.4",
]
[[package]]
name = "rustls"
version = "0.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d37e5e2290f3e040b594b1a9e04377c2c671f1a1cfd9bfdef82106ac1c113f84"
dependencies = [
"log",
"ring",
"sct 0.7.0",
"webpki 0.22.0",
]
[[package]]
name = "rustls-pemfile"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5eebeaeb360c87bfb72e84abdb3447159c0eaececf1bef2aecd65a8be949d1c9"
dependencies = [
"base64",
] ]
[[package]] [[package]]
@ -2431,16 +2374,6 @@ dependencies = [
"winapi-util", "winapi-util",
] ]
[[package]]
name = "schannel"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75"
dependencies = [
"lazy_static",
"winapi 0.3.9",
]
[[package]] [[package]]
name = "scopeguard" name = "scopeguard"
version = "1.1.0" version = "1.1.0"
@ -2457,6 +2390,16 @@ dependencies = [
"untrusted", "untrusted",
] ]
[[package]]
name = "sct"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4"
dependencies = [
"ring",
"untrusted",
]
[[package]] [[package]]
name = "sea-orm" name = "sea-orm"
version = "0.5.0" version = "0.5.0"
@ -2543,29 +2486,6 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "security-framework"
version = "2.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dc14f172faf8a0194a3aded622712b0de276821addc574fa54fc0a1167e10dc"
dependencies = [
"bitflags",
"core-foundation",
"core-foundation-sys",
"libc",
"security-framework-sys",
]
[[package]]
name = "security-framework-sys"
version = "2.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]] [[package]]
name = "semver" name = "semver"
version = "0.9.0" version = "0.9.0"
@ -2818,7 +2738,7 @@ dependencies = [
"parking_lot", "parking_lot",
"percent-encoding", "percent-encoding",
"rust_decimal", "rust_decimal",
"rustls", "rustls 0.19.1",
"serde", "serde",
"serde_json", "serde_json",
"sha2", "sha2",
@ -2830,8 +2750,8 @@ dependencies = [
"tokio-stream", "tokio-stream",
"url", "url",
"uuid", "uuid",
"webpki", "webpki 0.21.4",
"webpki-roots", "webpki-roots 0.21.1",
] ]
[[package]] [[package]]
@ -2863,7 +2783,7 @@ dependencies = [
"actix-rt 2.6.0", "actix-rt 2.6.0",
"once_cell", "once_cell",
"tokio 1.16.1", "tokio 1.16.1",
"tokio-rustls", "tokio-rustls 0.22.0",
] ]
[[package]] [[package]]
@ -2951,20 +2871,6 @@ dependencies = [
"unicode-xid", "unicode-xid",
] ]
[[package]]
name = "tempfile"
version = "3.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"
dependencies = [
"cfg-if 1.0.0",
"fastrand",
"libc",
"redox_syscall",
"remove_dir_all",
"winapi 0.3.9",
]
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.30" version = "1.0.30"
@ -3135,25 +3041,26 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "tokio-native-tls"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b"
dependencies = [
"native-tls",
"tokio 1.16.1",
]
[[package]] [[package]]
name = "tokio-rustls" name = "tokio-rustls"
version = "0.22.0" version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6"
dependencies = [ dependencies = [
"rustls", "rustls 0.19.1",
"tokio 1.16.1", "tokio 1.16.1",
"webpki", "webpki 0.21.4",
]
[[package]]
name = "tokio-rustls"
version = "0.23.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a27d5f2b839802bd8267fa19b0530f5a08b9c08cd417976be2a65d130fe1c11b"
dependencies = [
"rustls 0.20.2",
"tokio 1.16.1",
"webpki 0.22.0",
] ]
[[package]] [[package]]
@ -3608,13 +3515,32 @@ dependencies = [
"untrusted", "untrusted",
] ]
[[package]]
name = "webpki"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd"
dependencies = [
"ring",
"untrusted",
]
[[package]] [[package]]
name = "webpki-roots" name = "webpki-roots"
version = "0.21.1" version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940" checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940"
dependencies = [ dependencies = [
"webpki", "webpki 0.21.4",
]
[[package]]
name = "webpki-roots"
version = "0.22.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "552ceb903e957524388c4d3475725ff2c8b7960922063af6ce53c9a43da07449"
dependencies = [
"webpki 0.22.0",
] ]
[[package]] [[package]]

View File

@ -16,7 +16,7 @@ actix-web-actors = "4.0.0-beta.6"
chrono = { version = "0.4.19", features = ["serde"] } chrono = { version = "0.4.19", features = ["serde"] }
serde = { version = "1.0.136", features= [ "derive" ] } serde = { version = "1.0.136", features= [ "derive" ] }
serde_json = "1.0.78" serde_json = "1.0.78"
actix-web = "4.0.0-rc.2" actix-web = { version = "4.0.0-rc.2", features = ["rustls"] }
actix-rt = "2.6.0" actix-rt = "2.6.0"
tracing-test = "0.2.1" tracing-test = "0.2.1"
tracing-actix-web = "0.5.0-rc.1" tracing-actix-web = "0.5.0-rc.1"
@ -29,7 +29,8 @@ rand = "0.8.4"
tokio = { verison = "1", features=["full"] } tokio = { verison = "1", features=["full"] }
base64 = "0.13.0" base64 = "0.13.0"
sqlx = { version = "^0.5", features=["sqlite", "migrate"] } sqlx = { version = "^0.5", features=["sqlite", "migrate"] }
reqwest = "0.11.9" reqwest = { version = "0.11.9", features = ["rustls-tls"], default-features=false }
[target.'cfg(all(target_env = "musl", target_pointer_width = "64"))'.dependencies.jemallocator] [target.'cfg(all(target_env = "musl", target_pointer_width = "64"))'.dependencies.jemallocator]
version = "0.3" version = "0.3"

View File

@ -4,11 +4,10 @@ CREATE TABLE application (
app_name TEXT NOT NULL, app_name TEXT NOT NULL,
url TEXT NOT NULL, url TEXT NOT NULL,
description TEXT, description TEXT,
active Boolean NOT NULL DEFAULT 1, active Boolean DEFAULT 1 NOT NULL,
glyph TEXT, glyph TEXT,
application_category_id INTEGER, application_category_id INTEGER,
alive Boolean NOT NULL DEFAULT 1, enable_healthcheck Boolean DEFAULT 0 NOT NULL
enable_healthcheck Boolean NOT NULL DEFAULT 0
); );
CREATE TABLE application_category ( CREATE TABLE application_category (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,

View File

@ -89,11 +89,6 @@ pub mod test_prelude {
pub use crate::error::Result; pub use crate::error::Result;
pub use actix_web::dev::ServiceResponse; pub use actix_web::dev::ServiceResponse;
pub use actix_web::{test, web, App}; pub use actix_web::{test, web, App};
use sea_orm::sea_query::TableCreateStatement;
use sea_orm::ConnectionTrait;
use sea_orm::Database;
use sea_orm::DbBackend;
use sea_orm::Schema;
pub use sea_orm::{ pub use sea_orm::{
entity::prelude::*, entity::*, tests_cfg::*, DatabaseBackend, MockDatabase, MockExecResult, entity::prelude::*, entity::*, tests_cfg::*, DatabaseBackend, MockDatabase, MockExecResult,
Transaction, Transaction,
@ -102,22 +97,10 @@ pub mod test_prelude {
/// Sets up a testing state with an in-memory database and creates the scheme. /// Sets up a testing state with an in-memory database and creates the scheme.
pub async fn setup_state() -> Result<actix_web::web::Data<AppState>> { pub async fn setup_state() -> Result<actix_web::web::Data<AppState>> {
let db = Database::connect("sqlite::memory:").await?; let pool = sqlx::SqlitePool::connect("sqlite::memory:").await?;
let schema = Schema::new(DbBackend::Sqlite); sqlx::migrate!("./migrations").run(&pool).await?;
let stmt: TableCreateStatement = schema.create_table_from_entity(application::Entity); let db = sea_orm::SqlxSqliteConnector::from_sqlx_sqlite_pool(pool);
db.execute(db.get_database_backend().build(&stmt)).await?;
let stmt: TableCreateStatement =
schema.create_table_from_entity(application_category::Entity);
db.execute(db.get_database_backend().build(&stmt)).await?;
let stmt: TableCreateStatement = schema.create_table_from_entity(bookmark::Entity);
db.execute(db.get_database_backend().build(&stmt)).await?;
let stmt: TableCreateStatement = schema.create_table_from_entity(bookmark_category::Entity);
db.execute(db.get_database_backend().build(&stmt)).await?;
let stmt: TableCreateStatement = schema.create_table_from_entity(setting::Entity);
db.execute(db.get_database_backend().build(&stmt)).await?;
auth::generate_secret(&db).await?; auth::generate_secret(&db).await?;

View File

@ -62,7 +62,7 @@ impl actix_web::error::ResponseError for Error {
fn status_code(&self) -> actix_web::http::StatusCode { fn status_code(&self) -> actix_web::http::StatusCode {
match self.code { match self.code {
ErrorCode::UnAuthorized => StatusCode::UNAUTHORIZED, ErrorCode::UnAuthorized => StatusCode::UNAUTHORIZED,
ErrorCode::NoSetup => StatusCode::OK, ErrorCode::NoSetup => StatusCode::UPGRADE_REQUIRED,
_ => StatusCode::INTERNAL_SERVER_ERROR, _ => StatusCode::INTERNAL_SERVER_ERROR,
} }
} }

View File

@ -191,14 +191,14 @@ export default {
} }
}, },
async reload() { async reload() {
this.applications = (await axios.get("/api/applications")).data.items; this.applications = (await axios.get("/api/applications")).data.items || [];
this.applicationCategories = ( this.applicationCategories = (
await axios.get("/api/application_categories") await axios.get("/api/application_categories")
).data.items; ).data.items || [];
this.bookmarks = (await axios.get("/api/bookmarks")).data.items; this.bookmarks = (await axios.get("/api/bookmarks")).data.items || [];
this.bookmarkCategories = ( this.bookmarkCategories = (
await axios.get("/api/bookmark_categories") await axios.get("/api/bookmark_categories")
).data.items; ).data.items || [];
this.editApp = {}; this.editApp = {};
this.editAppCat = {}; this.editAppCat = {};