diff --git a/server/Cargo.lock b/server/Cargo.lock index 2b66a4946a..213ffa9a56 100644 --- a/server/Cargo.lock +++ b/server/Cargo.lock @@ -123,9 +123,9 @@ dependencies = [ [[package]] name = "actix-identity" -version = "0.6.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36e1cc6f95e245b2f3c6995df4e1c0c697704c48c28ec325d135a3ca039d4952" +checksum = "f2c99b7a5614b72a78f04aa2021e5370fc1aef2475fffeffc0c1266b99007062" dependencies = [ "actix-service", "actix-session", @@ -200,18 +200,17 @@ dependencies = [ [[package]] name = "actix-session" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e6a28f813a6671e1847d005cad0be36ae4d016287690f765c303379837c13d6" +checksum = "b671404ec72194d8af58c2bdaf51e3c477a0595056bd5010148405870dda8df2" dependencies = [ "actix-service", "actix-utils", "actix-web", "anyhow", - "async-trait", "derive_more", "rand 0.8.5", - "redis 0.23.3", + "redis 0.24.0", "serde", "serde_json", "tracing", @@ -3528,9 +3527,9 @@ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" [[package]] name = "redis" -version = "0.23.3" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f49cdc0bb3f412bf8e7d1bd90fe1d9eb10bc5c399ba90973c14662a27b3f8ba" +checksum = "c580d9cbbe1d1b479e8d67cf9daf6a62c957e6846048408b80b43ac3f6af84cd" dependencies = [ "arc-swap", "async-trait", diff --git a/server/Cargo.toml b/server/Cargo.toml index 0b8bd2e39d..08a10432ba 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -31,8 +31,8 @@ path = "src/bin/create-new-qdrant.rs" [dependencies] -actix-identity = { version = "0.6.0" } -actix-session = { version = "0.8.0", features = [ +actix-identity = { version = "0.7.1" } +actix-session = { version = "0.9.0", features = [ "redis-rs-session", "redis-rs-tls-session", ] } diff --git a/server/src/handlers/auth_handler.rs b/server/src/handlers/auth_handler.rs index d56bc529a1..4eede02f0a 100644 --- a/server/src/handlers/auth_handler.rs +++ b/server/src/handlers/auth_handler.rs @@ -24,6 +24,7 @@ use openidconnect::core::{CoreAuthenticationFlow, CoreClient, CoreProviderMetada use openidconnect::{AccessTokenHash, ClientId, IssuerUrl, Nonce}; use serde::{Deserialize, Serialize}; use serde_json::json; +use std::fs::read_to_string; use std::future::{ready, Ready}; use utoipa::{IntoParams, ToSchema}; @@ -558,3 +559,11 @@ pub async fn get_me( pub async fn health_check() -> Result { Ok(HttpResponse::Ok().finish()) } + +/// Local login page for cli +pub async fn login_cli() -> Result { + let html_page = read_to_string("src/public/login.html").map_err(|e| { + ServiceError::InternalServerError(format!("Could not read login page {}", e.to_string())) + })?; + Ok(HttpResponse::Ok().content_type("text/html").body(html_page)) +} diff --git a/server/src/lib.rs b/server/src/lib.rs index 95c0d23836..6415b829e2 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -474,6 +474,10 @@ pub async fn main() -> std::io::Result<()> { .service( web::redirect("/swagger-ui", "/swagger-ui/") ) + .service( + web::resource("/auth/cli") + .route(web::get().to(handlers::auth_handler::login_cli)) + ) // everything under '/api/' route .service( web::scope("/api") diff --git a/server/src/public/login.html b/server/src/public/login.html new file mode 100644 index 0000000000..34be952259 --- /dev/null +++ b/server/src/public/login.html @@ -0,0 +1,144 @@ + + + + + + Create API Key + + + +
+
+ + + +
+ +
+ + + +