Allow executing program to retrieve credentials

* config / authentication: permit to call external program for getting credentials

You can add into your ncspot/config.toml like this:

```
creds_username = "mylogin"
creds_passeval = "pass my_pass_path_to_spot_password"
```

Or using any password manager who send your password.to stdout.
If a newline is detected it will be automatically removed

* Move credential commands into separate structure

Also add an option for a username command

* Document credential commands

---------

Co-authored-by: Henrik Friedrichsen <henrik@affekt.org>
This commit is contained in:
inemajo
2023-03-01 11:28:11 +01:00
committed by GitHub
parent 3a3d8ae8b4
commit c2e030c2f0
4 changed files with 68 additions and 1 deletions

View File

@@ -191,7 +191,17 @@ fn main() -> Result<(), String> {
info!("Using cached credentials");
c
}
None => credentials_prompt(None)?,
None => {
info!("Attempting to resolve credentials via username/password commands");
let creds = cfg.values().credentials.clone().unwrap_or_default();
match (creds.username_cmd, creds.password_cmd) {
(Some(username_cmd), Some(password_cmd)) => {
authentication::credentials_eval(&username_cmd, &password_cmd)?
}
_ => credentials_prompt(None)?,
}
}
}
};