backend/controller/
config.rs

1//! `Config` endpoints.
2
3use actix_web::{get, HttpResponse};
4
5use crate::config::auth;
6use crate::model::dto::ConfigDto;
7
8/// Endpoint for fetching configuration for the frontend.
9#[allow(clippy::unused_async)]
10#[utoipa::path(
11    context_path = "/api/config",
12    responses(
13        (status = 200, description = "Fetch the config the frontend requires to run", body = ConfigDto)
14    )
15)]
16#[get("")]
17pub async fn get() -> HttpResponse {
18    let config = auth::Config::get();
19    let response = ConfigDto {
20        issuer_uri: config.openid_configuration.issuer.clone(),
21        client_id: config.client_id.clone(),
22        version: env!("CARGO_PKG_VERSION").to_owned(),
23    };
24    HttpResponse::Ok().json(response)
25}