-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for apikey based logins #187
base: main
Are you sure you want to change the base?
Conversation
fdacc67
to
d7a7cfd
Compare
I'd like to follow this one with few more changes along the road, but I feel like thse would warrant separate PRs:
With these changes all the auth strategies will be handled as first-class citizens and not just piggyback on the master password auth method. BTW I kind of defaulted to using the config file as a single source of truth defining what method we should use. |
Could you fix the conflicts? |
Sure, I'll try to get back to it during the weekend |
I forgot how big this MR is 😅 If you'd like to try this with a local build you'll have to:
Add Note: You'll be asked via pinentry for Bitwarden password before being asked for I've rebased and tested the login flows, but didn't really test refresh flows after the rebase (these require BW tokens to expire and take some time). Some unexpected errors may pop up after a day or two |
For something that uses an API key, which is commonly used for automation, this is not very intuitive. Wouldn't it be preferred it be prompted if unset in the configuration file - to allow people to not store the secret? My usecase for this feature is to simulate the bitwarden extension's ability to keep a session forever. And others may choose to use rbw in automation as well, so a feature like this would be nice to see. |
I suppose it could first try to get value from config and fallback to pinentry. It was implemented to handle unexpected sever changes that break other auth methods. Support for automation would be a nice addition I guess |
this MUST be reworked properly
PoCd, it's pretty ugly right now, whole MR requires a cleanup honestly. It's NOT mergable as-is new stuff:
|
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