aboutsummaryrefslogtreecommitdiffstats
path: root/src/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/api')
-rw-r--r--src/api/auth.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/api/auth.rs b/src/api/auth.rs
index 400feed..f85b64e 100644
--- a/src/api/auth.rs
+++ b/src/api/auth.rs
@@ -52,6 +52,13 @@ fn load_users(path: &str) -> anyhow::Result<HashMap<String, String>> {
Ok(users)
}
+/// The user names of the htpasswd file at `path` (`load_users`), sorted.
+pub(crate) fn htpasswd_names(path: &str) -> anyhow::Result<Vec<String>> {
+ let mut names: Vec<String> = load_users(path)?.into_keys().collect();
+ names.sort();
+ Ok(names)
+}
+
/// Who may use the HTTP API: the users of an htpasswd file (basic authentication),
/// and the user a reverse proxy in front names (`--user-header`), if it is one of
/// `--trusted-proxies`.