Add support for apikey based logins #187
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allows users to log in with
client_id
&client_secret
pair that can be obtained from Bitwarden.Apikey based login does not return
refresh_token
as part of the response, instead it's required to just reauthenticate with the credentials (same approach as in the official CLI).What was changed:
refresh_token
type was added to differentiate between the refresh flows required. SSO and email+password return therefresh_key
, apikey stores theclient_id
&client_secret
pair instead.This means that these credentials are stored on disk in plaintext, in the
rbw
's DB file.It's consistent with how it's done in Bitwarden's official CLI, they do it the same way
client_id
field was added to configclient_secret
is read via pinentryI also cleaned up a bit in
src/api.rs
, the apikey request is sent in three different places now, it looked bad without these changes:src/api.rs
device_id
andemail
are needed for the relogin with apikey (to run it exactly the same way as the initial login), I've initially kept these alongsideclient_id
andclient_secret
in the DB, but eventually changed to reading them from config. Thus addingdevice_id
function non-async variant.Tested (login + token refresh) the changes with all three flows we'd have now.
This topic started as part of #182
According to it, apikey strategy seems to be less fragile than the password based one, so maybe it'd be helpful for debugging issues in the future
CC @pfr-dev