diff options
author | Proudmuslim <proudmuslim-dev@protonmail.com> | 2023-07-21 05:58:40 +0000 |
---|---|---|
committer | Proudmuslim <proudmuslim-dev@protonmail.com> | 2023-07-21 05:58:40 +0000 |
commit | fc6e179d6e613d7274c3b3ee27f5d4f68d11b9e6 (patch) | |
tree | 4e8c87aa614d963db4014fffd44b9ef621f8a853 /src/args.rs | |
parent | Bump deps (diff) | |
download | miniserve-fc6e179d6e613d7274c3b3ee27f5d4f68d11b9e6.tar.gz miniserve-fc6e179d6e613d7274c3b3ee27f5d4f68d11b9e6.zip |
Add ability to read auth from file
Diffstat (limited to '')
-rw-r--r-- | src/args.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/args.rs b/src/args.rs index f7b42f1..020539a 100644 --- a/src/args.rs +++ b/src/args.rs @@ -72,6 +72,10 @@ pub struct CliArgs { )] pub auth: Vec<auth::RequiredAuth>, + /// Read authentication values from a file. + #[arg(long, value_hint = ValueHint::FilePath, env = "MINISERVE_AUTH_FILE")] + pub auth_file: Option<PathBuf>, + /// Use a specific route prefix #[arg(long = "route-prefix", env = "MINISERVE_ROUTE_PREFIX")] pub route_prefix: Option<String>, @@ -241,7 +245,7 @@ fn parse_interface(src: &str) -> Result<IpAddr, std::net::AddrParseError> { } /// Parse authentication requirement -fn parse_auth(src: &str) -> Result<auth::RequiredAuth, ContextualError> { +pub fn parse_auth(src: &str) -> Result<auth::RequiredAuth, ContextualError> { let mut split = src.splitn(3, ':'); let invalid_auth_format = Err(ContextualError::InvalidAuthFormat); |