Skip to content

Commit f65c0e2

Browse files
BlackDexdani-garcia
authored andcommittedJan 9, 2023
Validate YUBICO_SERVER string (#3003)
If the `YUBICO_SERVER` is defined to an empty string, the whole yubikey implementation doesn't work anymore. This PR adds a check for this variable that it at least starts with `https://`. Resolves #3003
1 parent 0f588ce commit f65c0e2

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed
 

Diff for: ‎src/config.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -698,8 +698,17 @@ fn validate_config(cfg: &ConfigItems) -> Result<(), Error> {
698698
err!("All Duo options need to be set for global Duo support")
699699
}
700700

701-
if cfg._enable_yubico && cfg.yubico_client_id.is_some() != cfg.yubico_secret_key.is_some() {
702-
err!("Both `YUBICO_CLIENT_ID` and `YUBICO_SECRET_KEY` need to be set for Yubikey OTP support")
701+
if cfg._enable_yubico {
702+
if cfg.yubico_client_id.is_some() != cfg.yubico_secret_key.is_some() {
703+
err!("Both `YUBICO_CLIENT_ID` and `YUBICO_SECRET_KEY` must be set for Yubikey OTP support")
704+
}
705+
706+
if let Some(yubico_server) = &cfg.yubico_server {
707+
let yubico_server = yubico_server.to_lowercase();
708+
if !yubico_server.starts_with("https://") {
709+
err!("`YUBICO_SERVER` must be a valid URL and start with 'https://'. Either unset this variable or provide a valid URL.")
710+
}
711+
}
703712
}
704713

705714
if cfg._enable_smtp {

0 commit comments

Comments
 (0)
Please sign in to comment.