kanidmd_core/https/
generic.rs
1use axum::extract::State;
2use axum::http::header::CONTENT_TYPE;
3use axum::response::{IntoResponse, Redirect};
4use axum::{Extension, Json};
5use kanidmd_lib::status::StatusRequestEvent;
6
7use super::middleware::KOpId;
8use super::views::constants::Urls;
9use super::ServerState;
10
11#[utoipa::path(
12 get,
13 path = "/status",
14 responses(
15 (status = 200, description = "Ok", content_type = "application/json"),
16 ),
17 tag = "system",
18
19)]
20pub async fn status(
22 State(state): State<ServerState>,
23 Extension(kopid): Extension<KOpId>,
24) -> Json<bool> {
25 state
26 .status_ref
27 .handle_request(StatusRequestEvent {
28 eventid: kopid.eventid,
29 })
30 .await
31 .into()
32}
33
34#[utoipa::path(
35 get,
36 path = "/robots.txt",
37 responses(
38 (status = 200, description = "Ok"),
39 ),
40 tag = "ui",
41 operation_id = "robots_txt",
42
43)]
44pub async fn robots_txt() -> impl IntoResponse {
45 (
46 [(CONTENT_TYPE, "text/plain;charset=utf-8")],
47 axum::response::Html(
48 r#"User-agent: *
49 Disallow: /
50"#,
51 ),
52 )
53}
54
55#[utoipa::path(
56 get,
57 path = Urls::WellKnownChangePassword.as_ref(),
58 responses(
59 (status = 303, description = "See other"),
60 ),
61 tag = "ui",
62)]
63pub async fn redirect_to_update_credentials() -> impl IntoResponse {
64 Redirect::to(Urls::UpdateCredentials.as_ref())
65}