Add OIDC well-known URI.
Only has a static URI for the keys endpoint. Need to work out how to build URIs for routes.
This commit is contained in:
parent
10fbaaddb8
commit
b6ad7bcdd2
19
src/main.rs
19
src/main.rs
|
@ -7,6 +7,7 @@ extern crate tokio;
|
||||||
|
|
||||||
#[macro_use] extern crate log;
|
#[macro_use] extern crate log;
|
||||||
|
|
||||||
|
#[macro_use(Serialize)]
|
||||||
extern crate serde_derive;
|
extern crate serde_derive;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
@ -217,6 +218,23 @@ fn get_keys(_req: Request<Body>) -> Response<Body> {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
struct OidcConfig {
|
||||||
|
pub jwks_uri: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn oidc_config(_req: Request<Body>) -> Response<Body> {
|
||||||
|
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<Body>) -> Response<Body> {
|
fn hello(_req: Request<Body>) -> Response<Body> {
|
||||||
Response::new(Body::from("Hi!"))
|
Response::new(Body::from("Hi!"))
|
||||||
}
|
}
|
||||||
|
@ -226,6 +244,7 @@ fn router_service() -> Result<RouterService, std::io::Error> {
|
||||||
.add(Route::get("/").using(hello))
|
.add(Route::get("/").using(hello))
|
||||||
.add(Route::post("/auth").using(auth_handler))
|
.add(Route::post("/auth").using(auth_handler))
|
||||||
.add(Route::get("/oauth2/keys").using(get_keys))
|
.add(Route::get("/oauth2/keys").using(get_keys))
|
||||||
|
.add(Route::get("/.well-known/openid-configuration").using(oidc_config))
|
||||||
.build();
|
.build();
|
||||||
Ok(RouterService::new(router))
|
Ok(RouterService::new(router))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue