diff --git a/src/api2/access.rs b/src/api2/access.rs index 6cfc4c81..852c57c5 100644 --- a/src/api2/access.rs +++ b/src/api2/access.rs @@ -13,6 +13,7 @@ use crate::auth_helpers::*; use crate::api2::types::*; pub mod user; +pub mod domain; fn authenticate_user(username: &str, password: &str) -> Result<(), Error> { @@ -137,6 +138,7 @@ const SUBDIRS: SubdirMap = &[ "ticket", &Router::new() .post(&API_METHOD_CREATE_TICKET) ), + ("domains", &domain::ROUTER), ("users", &user::ROUTER), ]; diff --git a/src/api2/access/domain.rs b/src/api2/access/domain.rs new file mode 100644 index 00000000..85594d65 --- /dev/null +++ b/src/api2/access/domain.rs @@ -0,0 +1,42 @@ +use failure::*; + +use serde_json::{json, Value}; + +use proxmox::api::api; +use proxmox::api::router::Router; + +use crate::api2::types::*; + +#[api( + returns: { + description: "List of realms.", + type: Array, + items: { + type: Object, + description: "User configuration (without password).", + properties: { + realm: { + description: "Realm ID.", + type: String, + }, + comment: { + schema: SINGLE_LINE_COMMENT_SCHEMA, + optional: true, + }, + }, + } + } +)] +/// Authentication domain/realm index. +/// +/// Anyone can access this, because we need that list for the login +/// box (before the user is authenticated). +fn list_domains() -> Result { + let mut list = Vec::new(); + list.push(json!({ "realm": "pam", "comment": "Linux PAM standard authentication" })); + list.push(json!({ "realm": "pbs", "comment": "Proxmox Backup authentication server" })); + Ok(list.into()) +} + +pub const ROUTER: Router = Router::new() + .get(&API_METHOD_LIST_DOMAINS); diff --git a/src/server/rest.rs b/src/server/rest.rs index 2efa2fde..39bccfd7 100644 --- a/src/server/rest.rs +++ b/src/server/rest.rs @@ -524,7 +524,10 @@ pub async fn handle_request(api: Arc, req: Request) -> Result