1 //! List Authentication domains/realms
4 use serde_json
::{json, Value}
;
6 use proxmox_router
::{Permission, Router, RpcEnvironment}
;
7 use proxmox_schema
::api
;
9 use pbs_api_types
::BasicRealmInfo
;
13 description
: "List of realms with basic info.",
20 description
: "Anyone can access this, because we need that list for the login box (before the user is authenticated).",
21 permission
: &Permission
::World
,
24 /// Authentication domain/realm index.
25 fn list_domains(rpcenv
: &mut dyn RpcEnvironment
) -> Result
<Vec
<BasicRealmInfo
>, Error
> {
26 let mut list
= Vec
::new();
28 list
.push(serde_json
::from_value(json
!({
31 "comment": "Linux PAM standard authentication",
32 "default": Some(true),
34 list
.push(serde_json
::from_value(json
!({
37 "comment": "Proxmox Backup authentication server",
40 let (config
, digest
) = pbs_config
::domains
::config()?
;
42 for (_
, (section_type
, v
)) in config
.sections
.iter() {
43 let mut entry
= v
.clone();
44 entry
["type"] = Value
::from(section_type
.clone());
45 list
.push(serde_json
::from_value(entry
)?
);
48 rpcenv
["digest"] = hex
::encode(&digest
).into();
53 pub const ROUTER
: Router
= Router
::new().get(&API_METHOD_LIST_DOMAINS
);