mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-23 20:47:01 +01:00
Cleanup spa handling (#1825)
This commit is contained in:
parent
8e1e533f40
commit
72bca853f7
|
@ -603,7 +603,35 @@ pub async fn oauth2_openid_discovery_get(
|
|||
.qe_r_ref
|
||||
.handle_oauth2_openid_discovery(client_id, kopid.eventid)
|
||||
.await;
|
||||
to_axum_response(res)
|
||||
|
||||
match res {
|
||||
Ok(dsc) => {
|
||||
// Humans may look at this so we pretty it.
|
||||
#[allow(clippy::unwrap_used)]
|
||||
let body = serde_json::to_string_pretty(&dsc).unwrap();
|
||||
#[allow(clippy::unwrap_used)]
|
||||
Response::builder()
|
||||
.status(StatusCode::OK)
|
||||
.header(ACCESS_CONTROL_ALLOW_ORIGIN, "*")
|
||||
.body(Body::from(body))
|
||||
.unwrap()
|
||||
}
|
||||
Err(e) => {
|
||||
error!(err = ?e, "Unable to access discovery info");
|
||||
let body = match serde_json::to_string(&e) {
|
||||
Ok(val) => val,
|
||||
Err(e) => {
|
||||
format!("{:?}", e)
|
||||
}
|
||||
};
|
||||
#[allow(clippy::unwrap_used)]
|
||||
Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.header(ACCESS_CONTROL_ALLOW_ORIGIN, "*")
|
||||
.body(Body::from(body))
|
||||
.unwrap()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn oauth2_openid_userinfo_get(
|
||||
|
|
Binary file not shown.
|
@ -151,6 +151,13 @@ impl Oauth2App {
|
|||
.set("content-type", "application/json")
|
||||
.expect_throw("failed to set header");
|
||||
|
||||
if let Some(bearer_token) = models::get_bearer_token() {
|
||||
request
|
||||
.headers()
|
||||
.set("authorization", &bearer_token)
|
||||
.expect_throw("failed to set authorisation header");
|
||||
}
|
||||
|
||||
let window = utils::window();
|
||||
let resp_value = JsFuture::from(window.fetch_with_request(&request)).await?;
|
||||
let resp: Response = resp_value.dyn_into().expect_throw("Invalid response type");
|
||||
|
|
Loading…
Reference in a new issue