diff --git a/src/main.rs b/src/main.rs index 2118e3a..8d0fffa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ use std::env; use std::sync::Arc; -use axum::{http::StatusCode, routing::get, Json, Router}; +use axum::{http::StatusCode, response::Html, routing::get, Json, Router}; use axum_oidc_client::authentication::AuthenticationLayer; use axum_oidc_client::authentication::builder::OAuthConfigurationBuilder; use axum_oidc_client::authentication::logout::handle_default_logout::DefaultLogoutHandler; @@ -13,6 +13,42 @@ use axum_oidc_client::authentication::CodeChallengeMethod; use base64::Engine; use serde::Serialize; +const INDEX_HTML: &str = r#" + + + + + Hello + + + + +
+
+ + +"#; + #[derive(Serialize)] struct HelloResponse { preferred_username: String, @@ -42,6 +78,10 @@ async fn hello(session: AuthSession) -> Result, StatusCode> Ok(Json(HelloResponse { preferred_username })) } +async fn index(_session: AuthSession) -> Html<&'static str> { + Html(INDEX_HTML) +} + #[tokio::main] async fn main() -> anyhow::Result<()> { let provider_url = env_required("OIDC_PROVIDER_URL"); @@ -85,6 +125,7 @@ async fn main() -> anyhow::Result<()> { let logout_handler = Arc::new(DefaultLogoutHandler); let app = Router::new() + .route("/", get(index)) .route("/hello", get(hello)) .layer(AuthenticationLayer::new( Arc::new(config),