Skip to content

Commit

Permalink
feat: flake/handle no user / update for auth0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
philipcristiano committed Mar 19, 2024
1 parent 5707a51 commit c3c00eb
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
13 changes: 12 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
];
};
}
Expand Down
31 changes: 20 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<service_conventions::oidc::OIDCUser>) -> 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()
}

0 comments on commit c3c00eb

Please sign in to comment.