From 818b254cefee3ac41758deda80bbc863086cadbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Thu, 8 Sep 2022 17:38:00 +0200 Subject: [PATCH] Implement config endpoint --- src/api/core/mod.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/api/core/mod.rs b/src/api/core/mod.rs index c54ebeb7..094863d6 100644 --- a/src/api/core/mod.rs +++ b/src/api/core/mod.rs @@ -16,7 +16,7 @@ pub fn routes() -> Vec { let mut device_token_routes = routes![clear_device_token, put_device_token]; let mut eq_domains_routes = routes![get_eq_domains, post_eq_domains, put_eq_domains]; let mut hibp_routes = routes![hibp_breach]; - let mut meta_routes = routes![alive, now, version]; + let mut meta_routes = routes![alive, now, version, config]; let mut routes = Vec::new(); routes.append(&mut accounts::routes()); @@ -200,3 +200,24 @@ pub fn now() -> Json { fn version() -> Json<&'static str> { Json(crate::VERSION.unwrap_or_default()) } + +#[get("/config")] +fn config() -> Json { + let domain = crate::CONFIG.domain(); + Json(json!({ + "version": crate::VERSION, + "gitHash": env!("GIT_REV"), + "server": { + "name": "Vaultwarden", + "url": "https://github.com/dani-garcia/vaultwarden" + }, + "environment": { + "vault": domain, + "api": format!("{domain}/api"), + "identity": format!("{domain}/identity"), + "admin": format!("{domain}/admin"), + "notifications": format!("{domain}/notifications"), + "sso": "", + }, + })) +}