diff --git a/Cargo.lock b/Cargo.lock index 59b994a..ad0bb86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2299,9 +2299,9 @@ dependencies = [ [[package]] name = "service_conventions" -version = "0.0.6" +version = "0.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a84d2020d045e0910941ccf77f603870f5598d75fb96edb6fd31a72b8b963061" +checksum = "5dd490018e4d6cead8f3df9c4f99efa47940495cf0ca0dbbd401cf5c03eea14d" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index e9657de..f58ddf6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,8 +16,8 @@ once_cell = "1.19.0" openidconnect = "3.5.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -service_conventions = { version = "0.0.6", features = ["tracing", "oidc"]} -#service_conventions = { git = "https://github.com/philipcristiano/rust_service_conventions.git", branch = "cookie-user", features = ["tracing", "oidc"]} +service_conventions = { version = "0.0.7", features = ["tracing", "oidc"]} +#service_conventions = { git = "https://github.com/philipcristiano/rust_service_conventions.git", branch = "default-oidc", features = ["tracing", "oidc"]} tokio = { version = "1.36.0", features = ["full"] } toml = "0.8.12" tonic = { version = "0.11.0", features = ["tls", "tls-roots"] } diff --git a/flake.nix b/flake.nix index e77ca44..c84a806 100644 --- a/flake.nix +++ b/flake.nix @@ -17,8 +17,19 @@ { devShells.default = mkShell { buildInputs = [ - rust-bin.stable.latest.default + (rust-bin.stable.latest.default.override { + extensions = [ "rust-src" "rustfmt" ]; + }) + rust-analyzer + pkgs.postgresql_16 + pkgs.tailwindcss + pkgs.foreman + pkgs.openssl # native-tls is included in cargo, needs work to remove + pkgs.atlas + ] ++ + pkgs.lib.optionals pkgs.stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security # Should only be for darwin + darwin.apple_sdk.frameworks.SystemConfiguration ]; }; } diff --git a/src/main.rs b/src/main.rs index aa10a2c..598dc6d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -77,18 +77,27 @@ async fn root() -> Response { .into_response() } -async fn user_handler(user: service_conventions::oidc::OIDCUser) -> Response { - html! { - (DOCTYPE) - p { "Welcome! " ( user.id)} - @if let Some(name) = user.name { - p{ ( name ) } - } - @if let Some(email) = user.email { - p{ ( email ) } - } +async fn user_handler(user: Option) -> Response { + if let Some(user) = user { + html! { + (DOCTYPE) + p { "Welcome! " ( user.id)} + @if let Some(name) = user.name { + p{ ( name ) } + } + @if let Some(email) = user.email { + p{ ( email ) } + } + a href="/oidc/login" { "Login" } + } + .into_response() + } else { + + html! { + (DOCTYPE) + p { "Welcome! You need to login" } a href="/oidc/login" { "Login" } + }.into_response() } - .into_response() }