diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-10-27 05:38:03 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-10-27 05:44:08 -0400 |
commit | 9acabc3a7497e3eb3536992212d34f77a649ae16 (patch) | |
tree | e1433fe36c6768704ea63443910731c4ad7fbcc1 /src/bin/rbw/main.rs | |
parent | eb5e4ea7bcc3008a8d06da6884ee9713f8df0034 (diff) | |
download | rbw-9acabc3a7497e3eb3536992212d34f77a649ae16.tar.gz rbw-9acabc3a7497e3eb3536992212d34f77a649ae16.zip |
start working on apikey authentication
not entirely working yet, because api keys aren't allowed to use the
offline_access scope which provides access to the oauth refresh token.
we will probably need to move to using stable device identifiers (should
be able to generate one when the config is first created) and move this
logic to a separate "rbw register" command which just does an apikey
login but doesn't try to store any data, and then use the normal login
flow after that
Diffstat (limited to 'src/bin/rbw/main.rs')
-rw-r--r-- | src/bin/rbw/main.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/bin/rbw/main.rs b/src/bin/rbw/main.rs index e6e1249..2612398 100644 --- a/src/bin/rbw/main.rs +++ b/src/bin/rbw/main.rs @@ -18,7 +18,13 @@ enum Opt { }, #[structopt(about = "Log in to the Bitwarden server")] - Login, + Login { + #[structopt( + long, + help = "Log in to the Bitwarden server using your user API key (see https://bitwarden.com/help/article/personal-api-key/)" + )] + apikey: bool, + }, #[structopt(about = "Unlock the local Bitwarden database")] Unlock, @@ -214,7 +220,7 @@ impl Opt { Self::Config { config } => { format!("config {}", config.subcommand_name()) } - Self::Login => "login".to_string(), + Self::Login { .. } => "login".to_string(), Self::Unlock => "unlock".to_string(), Self::Unlocked => "unlocked".to_string(), Self::Sync => "sync".to_string(), @@ -284,7 +290,7 @@ fn main(opt: Opt) { Config::Set { key, value } => commands::config_set(key, value), Config::Unset { key } => commands::config_unset(key), }, - Opt::Login => commands::login(), + Opt::Login { apikey } => commands::login(*apikey), Opt::Unlock => commands::unlock(), Opt::Unlocked => commands::unlocked(), Opt::Sync => commands::sync(), |