diff --git a/Cargo.lock b/Cargo.lock index 292889c..8356480 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,27 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "alloc-no-stdlib" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" + +[[package]] +name = "alloc-stdlib" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" +dependencies = [ + "alloc-no-stdlib", +] + [[package]] name = "ansi_term" version = "0.12.1" @@ -77,6 +98,20 @@ dependencies = [ "toml", ] +[[package]] +name = "async-compression" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "345fd392ab01f746c717b1357165b76f0b67a60192007b234058c9045fdcf695" +dependencies = [ + "brotli", + "flate2", + "futures-core", + "memchr", + "pin-project-lite", + "tokio", +] + [[package]] name = "async-lock" version = "2.5.0" @@ -226,6 +261,27 @@ dependencies = [ "generic-array", ] +[[package]] +name = "brotli" +version = "3.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1a0b1dbcc8ae29329621f8d4f0d835787c1c38bb1401979b49d13b0b305ff68" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor", +] + +[[package]] +name = "brotli-decompressor" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ad2d4653bf5ca36ae797b1f4bb4dbddb60ce49ca4aed8a2ce4829f60425b80" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", +] + [[package]] name = "bumpalo" version = "3.9.1" @@ -284,6 +340,15 @@ dependencies = [ "libc", ] +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if 1.0.0", +] + [[package]] name = "crypto-common" version = "0.1.3" @@ -348,6 +413,16 @@ version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71" +[[package]] +name = "flate2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + [[package]] name = "fnv" version = "1.0.7" @@ -614,6 +689,15 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" +[[package]] +name = "iri-string" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f0f7638c1e223529f1bfdc48c8b133b9e0b434094d1d28473161ee48b235f78" +dependencies = [ + "nom", +] + [[package]] name = "itoa" version = "1.0.1" @@ -728,6 +812,15 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" +[[package]] +name = "miniz_oxide" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" +dependencies = [ + "adler", +] + [[package]] name = "mio" version = "0.8.0" @@ -1365,6 +1458,8 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c530c8675c1dbf98facee631536fa116b5fb6382d7dd6dc1b118d970eafe3ba" dependencies = [ + "async-compression", + "base64", "bitflags", "bytes", "futures-core", @@ -1373,6 +1468,7 @@ dependencies = [ "http-body", "http-range-header", "httpdate", + "iri-string", "mime", "mime_guess", "percent-encoding", @@ -1383,6 +1479,7 @@ dependencies = [ "tower-layer", "tower-service", "tracing", + "uuid", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 65b6f1f..392fc60 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,4 +19,4 @@ oauth2 = "4.1" reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "json"] } headers = "0.3" http = "0.2" -tower-http = { version = "0.3.4", features = ["fs", "trace"] } \ No newline at end of file +tower-http = { version = "0.3.4", features = ["full"] } \ No newline at end of file diff --git a/src/db.rs b/src/db.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/main.rs b/src/main.rs index f3cfe9a..90bd8f9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,12 +12,14 @@ use axum::{ header::SET_COOKIE, header::{HeaderMap, HeaderValue}, StatusCode, + Request, + Uri }, response::{Html, IntoResponse, Redirect, Response}, routing::{get, get_service}, - Router, + Router, body::{BoxBody, boxed}, }; -use http::header; +use http::{header}; use oauth2::{ basic::BasicClient, reqwest::async_http_client, AuthUrl, AuthorizationCode, ClientId, PkceCodeChallenge, RedirectUrl, Scope, TokenUrl, @@ -25,7 +27,7 @@ use oauth2::{ }; use serde::{Deserialize, Serialize}; use std::{env, net::SocketAddr, collections::HashMap}; -use tower_http::{services::ServeDir}; +use tower_http::services::ServeDir; use uuid::Uuid; const COOKIE_NAME: &str = "SESSION"; @@ -58,11 +60,16 @@ async fn main() { // Get the client structures let facebook_oauth_client = facebook_oauth_client(); let discord_oauth_client = discord_oauth_client(); + let google_oauth_client = google_oauth_client(); // Get oauth clients for the hashmap //oauth_clients.insert("Google".to_string(), google_oauth_client); oauth_clients.insert("Facebook", facebook_oauth_client); oauth_clients.insert("Discord", discord_oauth_client); + oauth_clients.insert("Google", google_oauth_client); + + //Static files are served from here + let service = ServeDir::new("templates"); // build our application with a route let app = Router::new() @@ -85,7 +92,7 @@ async fn main() { .route("/google_auth", get(google_auth)) .route("/facebook_auth", get(facebook_auth)) .route("/discord_auth", get(discord_auth)) - .route("/auth/callback", get(google_authorized)) + .route("/auth/google", get(google_authorized)) .route("/auth/facebook", get(facebook_authorized)) .route("/auth/discord", get(discord_authorized)) .layer(Extension(store)) @@ -365,7 +372,7 @@ async fn facebook_auth() -> impl IntoResponse { .url(); // Redirect to Google's oauth service - Redirect::to(auth_url.to_string().parse().unwrap()) + Redirect::to(&auth_url.to_string()) } async fn discord_auth() -> impl IntoResponse { @@ -489,11 +496,11 @@ async fn facebook_authorized( let mut headers = HeaderMap::new(); headers.insert(SET_COOKIE, cookie.parse().unwrap()); - (headers, Redirect::to("/dashboard".parse().unwrap())) + (headers, Redirect::to(&"/dashboard")) } else { let mut headers = HeaderMap::new(); - (headers, Redirect::to("/".parse().unwrap())) + (headers, Redirect::to(&"/")) } } diff --git a/templates/assets/icons/numix-circle/discord.svg b/templates/assets/icons/numix-circle/discord.svg new file mode 100644 index 0000000..5dc19e0 --- /dev/null +++ b/templates/assets/icons/numix-circle/discord.svg @@ -0,0 +1,26 @@ + diff --git a/templates/assets/icons/numix-circle/web-facebook.svg b/templates/assets/icons/numix-circle/web-facebook.svg new file mode 100644 index 0000000..6266011 --- /dev/null +++ b/templates/assets/icons/numix-circle/web-facebook.svg @@ -0,0 +1,18 @@ + diff --git a/templates/assets/icons/numix-circle/web-google.svg b/templates/assets/icons/numix-circle/web-google.svg new file mode 100644 index 0000000..5845fad --- /dev/null +++ b/templates/assets/icons/numix-circle/web-google.svg @@ -0,0 +1,18 @@ + diff --git a/templates/login.html b/templates/login.html index ee91ea3..dc0dc8e 100644 --- a/templates/login.html +++ b/templates/login.html @@ -31,15 +31,20 @@ Sign Up
Forgot your password?
--> -
+