diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 22fb8c4..a62fe1d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,8 +12,6 @@ test: script: - mkdir dist - touch dist/index.html - - apt-get update - - apt-get -y install pkg-config - cargo test build-ui: @@ -40,8 +38,6 @@ build-x64-bin: rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH script: - - apt-get update - - apt-get -y install libssl-dev pkg-config - cargo build --release - cd target/release - tar -czf ../../vade-linux-x64.tar.gz vade diff --git a/Cargo.lock b/Cargo.lock index 564ef97..3bf214e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -154,6 +154,7 @@ dependencies = [ "actix-codec 0.4.2", "actix-rt 2.6.0", "actix-service 2.0.2", + "actix-tls 3.0.2", "actix-utils 3.0.0", "ahash", "base64", @@ -355,6 +356,24 @@ dependencies = [ "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]] name = "actix-utils" version = "2.0.0" @@ -400,7 +419,7 @@ dependencies = [ "actix-service 1.0.6", "actix-testing", "actix-threadpool", - "actix-tls", + "actix-tls 2.0.0", "actix-utils 2.0.0", "actix-web-codegen 0.4.0", "awc", @@ -437,6 +456,7 @@ dependencies = [ "actix-rt 2.6.0", "actix-server 2.0.0", "actix-service 2.0.2", + "actix-tls 3.0.2", "actix-utils 3.0.0", "actix-web-codegen 0.5.0-rc.2", "ahash", @@ -871,22 +891,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "cpufeatures" version = "0.2.1" @@ -1031,15 +1035,6 @@ dependencies = [ "syn", ] -[[package]] -name = "fastrand" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" -dependencies = [ - "instant", -] - [[package]] name = "firestorm" version = "0.5.0" @@ -1076,21 +1071,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "form_urlencoded" version = "1.0.1" @@ -1415,16 +1395,16 @@ dependencies = [ ] [[package]] -name = "hyper-tls" -version = "0.5.0" +name = "hyper-rustls" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +checksum = "d87c48c02e0dc5e3b849a2041db3029fd066650f8f717c07bf8ed78ccb895cac" dependencies = [ - "bytes 1.1.0", + "http", "hyper", - "native-tls", + "rustls 0.20.2", "tokio 1.16.1", - "tokio-native-tls", + "tokio-rustls 0.23.2", ] [[package]] @@ -1790,24 +1770,6 @@ dependencies = [ "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]] name = "net2" version = "0.2.37" @@ -1911,39 +1873,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "ouroboros" version = "0.14.0" @@ -2263,15 +2192,6 @@ version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "reqwest" version = "0.11.9" @@ -2287,24 +2207,26 @@ dependencies = [ "http", "http-body", "hyper", - "hyper-tls", + "hyper-rustls", "ipnet", "js-sys", "lazy_static", "log", "mime", - "native-tls", "percent-encoding", "pin-project-lite 0.2.8", + "rustls 0.20.2", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", "tokio 1.16.1", - "tokio-native-tls", + "tokio-rustls 0.23.2", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", + "webpki-roots 0.22.2", "winreg 0.7.0", ] @@ -2406,8 +2328,29 @@ dependencies = [ "base64", "log", "ring", - "sct", - "webpki", + "sct 0.6.1", + "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]] @@ -2431,16 +2374,6 @@ dependencies = [ "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]] name = "scopeguard" version = "1.1.0" @@ -2457,6 +2390,16 @@ dependencies = [ "untrusted", ] +[[package]] +name = "sct" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "sea-orm" version = "0.5.0" @@ -2543,29 +2486,6 @@ dependencies = [ "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]] name = "semver" version = "0.9.0" @@ -2818,7 +2738,7 @@ dependencies = [ "parking_lot", "percent-encoding", "rust_decimal", - "rustls", + "rustls 0.19.1", "serde", "serde_json", "sha2", @@ -2830,8 +2750,8 @@ dependencies = [ "tokio-stream", "url", "uuid", - "webpki", - "webpki-roots", + "webpki 0.21.4", + "webpki-roots 0.21.1", ] [[package]] @@ -2863,7 +2783,7 @@ dependencies = [ "actix-rt 2.6.0", "once_cell", "tokio 1.16.1", - "tokio-rustls", + "tokio-rustls 0.22.0", ] [[package]] @@ -2951,20 +2871,6 @@ dependencies = [ "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]] name = "thiserror" version = "1.0.30" @@ -3135,25 +3041,26 @@ dependencies = [ "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]] name = "tokio-rustls" version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" dependencies = [ - "rustls", + "rustls 0.19.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]] @@ -3608,13 +3515,32 @@ dependencies = [ "untrusted", ] +[[package]] +name = "webpki" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "webpki-roots" version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940" 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]] diff --git a/Cargo.toml b/Cargo.toml index 97f57ef..bc2361a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ actix-web-actors = "4.0.0-beta.6" chrono = { version = "0.4.19", features = ["serde"] } serde = { version = "1.0.136", features= [ "derive" ] } 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" tracing-test = "0.2.1" tracing-actix-web = "0.5.0-rc.1" @@ -29,7 +29,8 @@ rand = "0.8.4" tokio = { verison = "1", features=["full"] } base64 = "0.13.0" 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] version = "0.3" diff --git a/migrations/20220203034730_create-initial-table.sql b/migrations/20220203034730_create-initial-table.sql index 9677b35..4b6c083 100644 --- a/migrations/20220203034730_create-initial-table.sql +++ b/migrations/20220203034730_create-initial-table.sql @@ -4,11 +4,10 @@ CREATE TABLE application ( app_name TEXT NOT NULL, url TEXT NOT NULL, description TEXT, - active Boolean NOT NULL DEFAULT 1, + active Boolean DEFAULT 1 NOT NULL, glyph TEXT, application_category_id INTEGER, - alive Boolean NOT NULL DEFAULT 1, - enable_healthcheck Boolean NOT NULL DEFAULT 0 + enable_healthcheck Boolean DEFAULT 0 NOT NULL ); CREATE TABLE application_category ( id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, diff --git a/src/api/mod.rs b/src/api/mod.rs index 5bf6b6f..8a6b1bd 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -89,11 +89,6 @@ pub mod test_prelude { pub use crate::error::Result; pub use actix_web::dev::ServiceResponse; 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::{ entity::prelude::*, entity::*, tests_cfg::*, DatabaseBackend, MockDatabase, MockExecResult, Transaction, @@ -102,22 +97,10 @@ pub mod test_prelude { /// Sets up a testing state with an in-memory database and creates the scheme. pub async fn setup_state() -> Result> { - let db = Database::connect("sqlite::memory:").await?; - let schema = Schema::new(DbBackend::Sqlite); + let pool = sqlx::SqlitePool::connect("sqlite::memory:").await?; + sqlx::migrate!("./migrations").run(&pool).await?; - let stmt: TableCreateStatement = schema.create_table_from_entity(application::Entity); - 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?; + let db = sea_orm::SqlxSqliteConnector::from_sqlx_sqlite_pool(pool); auth::generate_secret(&db).await?; diff --git a/src/error.rs b/src/error.rs index 475a2e7..008bb95 100644 --- a/src/error.rs +++ b/src/error.rs @@ -62,7 +62,7 @@ impl actix_web::error::ResponseError for Error { fn status_code(&self) -> actix_web::http::StatusCode { match self.code { ErrorCode::UnAuthorized => StatusCode::UNAUTHORIZED, - ErrorCode::NoSetup => StatusCode::OK, + ErrorCode::NoSetup => StatusCode::UPGRADE_REQUIRED, _ => StatusCode::INTERNAL_SERVER_ERROR, } } diff --git a/src/ui/views/Dashboard.vue b/src/ui/views/Dashboard.vue index 874577c..4027bfe 100644 --- a/src/ui/views/Dashboard.vue +++ b/src/ui/views/Dashboard.vue @@ -191,14 +191,14 @@ export default { } }, async reload() { - this.applications = (await axios.get("/api/applications")).data.items; + this.applications = (await axios.get("/api/applications")).data.items || []; this.applicationCategories = ( await axios.get("/api/application_categories") - ).data.items; - this.bookmarks = (await axios.get("/api/bookmarks")).data.items; + ).data.items || []; + this.bookmarks = (await axios.get("/api/bookmarks")).data.items || []; this.bookmarkCategories = ( await axios.get("/api/bookmark_categories") - ).data.items; + ).data.items || []; this.editApp = {}; this.editAppCat = {};