doy / rbw

unofficial bitwarden cli
https://git.tozt.net/rbw
Other
573 stars 82 forks source link

"rbw login: failed to log in to bitwarden instance: Username or password is incorrect. Try again." #145

Closed WxNzEMof closed 6 months ago

WxNzEMof commented 7 months ago

Today I noticed that I can no longer log in with rbw. It does not accept my password.

I noticed that others have reported this problem in #32 and #88, though originally those issues were filed for different problems, so I'm creating an issue for this specific problem. Hope this helps.

rjp commented 7 months ago

Also getting this. Been digging in to see if I can figure out if things are going wrong in rbw but nothing useful yet.

carlosala commented 7 months ago

Same here!

augustebaum commented 7 months ago

Same also; this seemed to coincide with my swapping i3 for GNOME, but this issue tells me there is something deeper happening.

JeffDess commented 7 months ago

@augustebaum I don't think it's related to a DE/WM, I'm having the same in Plasma connecting to the default API. Maybe BW changed something recently?

valentingregoire commented 7 months ago

I have this issue with a fresh installation. I can login on both the Chrome extension and the fedora app, yet not with the cli. The only thin I set is the email: rbw config set email my@email.com because the rest should be the default. When entering my password, the login fails... Could this be a certificate issue? I didn't configure a certificate in the app neither, but maybe that is using the chrome certs?

carlosala commented 7 months ago

Was someone able to debug it? I really need rbw in my daily workflow🥲

joelsleeba commented 7 months ago
❯ rbw config show
{
  "email": "******@****.com",
  "base_url": "https://api.bitwarden.com/",
  "identity_url": null,
  "notifications_url": null,
  "lock_timeout": 3600,
  "sync_interval": 3600,
  "pinentry": "pinentry-gnome3",
  "client_cert_path": null
}

❯ cat .local/share/rbw/agent.err
websocket error: Io(Kind(UnexpectedEof))
websocket error: Protocol(ResetWithoutClosingHandshake)
websocket error: Protocol(ResetWithoutClosingHandshake)
websocket error: Protocol(ResetWithoutClosingHandshake)
websocket error: Protocol(ResetWithoutClosingHandshake)
websocket error: Protocol(ResetWithoutClosingHandshake)
failed to sync: failed to load db from /home/user/.cache/rbw/https%3A%2F%2Fapi.bitwarden.com%2F:******@****.com.json: No such file or directory (os error 2)

I got the same issue. I tried with default base_url and pinentry. Same error

❯ rbw login
rbw login: failed to log in to bitwarden instance: failed to parse JSON: EOF while parsing a value at line 1 column 0

rbw 1.8.3 linux 6.6.3.arch1-1

arcstur commented 7 months ago

Same here. Trying rbw register (and putting client id and secret) is returning

rbw register: failed to log in to bitwarden instance: api request returned error: 400

rbw 1.8.3 linux 6.6.4-arch1-1

rjc commented 7 months ago

Same here, with the exception that I seem to be able to register with rbw register but am being re-prompted for password constantly with pinentry claiming it isn't correct.

Edit: this is both on a machine where rbw was working previously, and on a new one.

rjp commented 7 months ago

I've done some debugging and I think that whilst rbw might have some issues (the 400 response, perhaps), I can't get anything other than a 500 back from the bitwarden API by hand following the API descriptions I've found elsewhere. Will have a look at vaultwarden and see if that gives me any clues (assuming that vw is still compatible with the bw API!)

rjp commented 7 months ago

Have tested against vaultwarden and rbw works fine there. Unhelpful, I know, but it really does seem like bitwarden are doing something weird that isn't specified in their API documentation (which is pretty terrible.)

yazgoo commented 6 months ago

Until this is fixed I'm using this script to emulate my usage of it, more precisely:

All this based on official CLI client (bw)

:warning: this stores the session in a local file with octal mode 600, use at your own risk

just name this script rbw, make it executable and put it in your path and you should be good.

to log in just do a rbw sync

#!/bin/env bash
set -eu -o pipefail
# emulate rbw wit bw

session_path="$HOME/.local/my_local_file"

bwu() {
    [ -e  "$session_path" ] && source "$session_path"
    BW_STATUS=$(bw status | jq -r .status)
    case "$BW_STATUS" in
    "unauthenticated")
        echo "Logging into BitWarden" >&2
        export BW_SESSION="$(bw login --raw)"
        ;;
    "locked")
        echo "Unlocking Vault" >&2
        export BW_SESSION="$(bw unlock --raw)"
        ;;
    "unlocked")
        echo "Vault is unlocked" >&2
        ;;
    *)
        echo "Unknown Login Status: $BW_STATUS" >&2
        return 1
        ;;
    esac
    bw sync >&2
    echo "export BW_SESSION=\"$BW_SESSION\"" > "$session_path"
    chmod 600 "$session_path"
}

if [ "$#" -eq 0 ]
then
    echo "Usage: rbw <get|sync> [options] <item>"
    exit
fi
case "$1" in
"get")
    source "$session_path"
    shift
    full=0
    for arg in "$@"
    do
        if [ "$arg" = "--full" ]
        then
            full=1
            shift
        fi
    done
    id=$(bw list items --search "$1" |  jq -r ".[] | select(.name==\"$1\") | .id")
    if [ "$full" = "1" ]
    then
        json="$(bw get item "$id")"
        echo "$json" | jq -r '.login.password' | tail -1
        echo "Username: $(echo "$json" | jq -r '.login.username' | tail -1)"
        uris="$(echo "$json" | jq -r '.login.uris')"
        [ "$uris" != "null" ] && echo "URI: $(echo "$json" | jq -r '.login.uris[].uri' | tail -1)"
    else
        bw get item "$id" | jq -r '.login.password' 
    fi
    ;;
"sync")
    bwu 
    ;;
esac
Msouza91 commented 6 months ago

Has anyone else tested #151 fix? I removed previous version of rbw and installed his revision with the proposed fix, but still getting the error message.

rjc commented 6 months ago

I've just tested the #151 fix - it does resolve the issue!

joelsleeba commented 6 months ago

151 fixes it! yayy!!

00sapo commented 6 months ago

Confirmed, it works

Msouza91 commented 6 months ago

I might be doing something wrong here, I did and rbw purge, deleted the config file, uninstalled the previous version of rbw, then installed the one from the PR, killed rbw-agent and rebooted my computer, not all at the same time, but that is all what I have done so far and still getting the error message, I checked the cargo checkouts folder and I have the code with the fix in the version installed on my PC. Thoroughly confused here :( I was so looking forward to try this with rofi-rbw, but I seem to be suffering from a major case of Skill Issue, not sure where else to look to solve this for me...

rjc commented 6 months ago

@Msouza91 Did your run rbw register?

Msouza91 commented 6 months ago

@rjc Register returns 400 as well, after input of the id and secret. image

rjc commented 6 months ago

@Msouza91 Are you a .eu user by any chance? If so, check the issue #148. If not, try on another machine where you previously hadn't used rbw. If it still doesn't work, try rotating the key and/or bumping PBKDF2 rounds. Other than that, I'm running out of ideas.

BTW, I've tested on macOS 14.2.1 and OpenBSD -current.

Msouza91 commented 6 months ago

Regular bitwarden.com user, will try the PBK parameter and rotating keys, thanks for the pointers.

Msouza91 commented 6 months ago

@rjc I was using Argo2id changed back to PBK, still didn't work for me after rotating keys, I'm at a loss, will try a minimal setup on a VM later and see what happens.

00sapo commented 6 months ago

I might be doing something wrong here, I did and rbw purge, deleted the config file, uninstalled the previous version of rbw, then installed the one from the PR, killed rbw-agent and rebooted my computer, not all at the same time, but that is all what I have done so far and still getting the error message, I checked the cargo checkouts folder and I have the code with the fix in the version installed on my PC. Thoroughly confused here :( I was so looking forward to try this with rofi-rbw, but I seem to be suffering from a major case of Skill Issue, not sure where else to look to solve this for me...

Try which rbw to check you have not other installations hiding the cargo installation. Then, remove the repo in the .cargo folder and retry (I used --branch option, but --ref should work the same).

Msouza91 commented 6 months ago

@00sapo Well, I only had cargo installed through cargo from the beginning, uninstalled the main version and used the -rev command from the PR to install it again, but didn't work for me, didn't get the time to test on a VM, but it wouldn't change much if it worked on the VM since I can't figure out what is wrong in my main machine. rbw login returns the same error image

00sapo commented 6 months ago

It says "rbw 1.8.3 is already installed". Remove it and install or use "--force"...