diff --git a/src/main.rs b/src/main.rs index 48ce23c..292b171 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,6 +7,7 @@ extern crate tokio; #[macro_use] extern crate log; +#[macro_use(Serialize)] extern crate serde_derive; use std::env; @@ -217,6 +218,23 @@ fn get_keys(_req: Request) -> Response { .unwrap() } +#[derive(Debug, Serialize)] +struct OidcConfig { + pub jwks_uri: String, +} + +fn oidc_config(_req: Request) -> Response { + let config = OidcConfig { + jwks_uri: "https://auth.xeen.dev/oauth2/keys".to_string(), + }; + let config_json = serde_json::to_string(&config).unwrap(); + Response::builder() + .status(StatusCode::OK) + .header("Content-Type", "application/json") + .body(Body::from(config_json)) + .unwrap() +} + fn hello(_req: Request) -> Response { Response::new(Body::from("Hi!")) } @@ -226,6 +244,7 @@ fn router_service() -> Result { .add(Route::get("/").using(hello)) .add(Route::post("/auth").using(auth_handler)) .add(Route::get("/oauth2/keys").using(get_keys)) + .add(Route::get("/.well-known/openid-configuration").using(oidc_config)) .build(); Ok(RouterService::new(router)) }