Closed phylor closed 3 years ago
this isn't correct - i have always had my own private server configured with a trailing /
, and it works fine. can you give more details about how you determined that this was the problem?
@doy Strange. There must be something different in our configurations/setups.
Here my flow to reproduce the issue:
$ cat ~/.config/rbw/config.json
{"email":"myuser@example.com","base_url":"https://bitwarden.example.com","identity_url":null,"lock_timeout":3600,"pinentry":"pinentry"}
$ rbw ls
# works fine
$ vim # add trailing slash
$ cat ~/.config/rbw/config.json
{"email":"myuser@example.com","base_url":"https://bitwarden.example.com/","identity_url":null,"lock_timeout":3600,"pinentry":"pinentry"}
$ rbw ls # I'm prompted for my password, I enter it and then the following error is displayed
rbw list: failed to log in to bitwarden instance: failed to parse JSON: .: EOF while parsing a value at line 1 column 0: EOF while parsing a value at line 1 column 0
Removing the trailing slash from the base_url
, makes everything behave normally again.
The bitwarden server logs say:
bitwarden-api | info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
bitwarden-api | Request starting HTTP/1.0 POST http://bitwarden.example.com/accounts/prelogin application/json 24
bitwarden-api | info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
bitwarden-api | Executing endpoint 'Bit.Api.Controllers.AccountsController.PostPrelogin (Api)'
bitwarden-api | info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[3]
bitwarden-api | Route matched with {action = "PostPrelogin", controller = "Accounts"}. Executing controller action with signature System.Threading.Tasks.Task`1[Bit.Core.Models.Api.PreloginResponseModel] PostPrelogin(Bit.Core.Models.Api.PreloginRequestModel) on controller Bit.Api.Controllers.AccountsController (Api).
bitwarden-api | info: Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor[1]
bitwarden-api | Executing ObjectResult, writing value of type 'Bit.Core.Models.Api.PreloginResponseModel'.
bitwarden-api | info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[2]
bitwarden-api | Executed action Bit.Api.Controllers.AccountsController.PostPrelogin (Api) in 146.5445ms
bitwarden-api | info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
bitwarden-api | Executed endpoint 'Bit.Api.Controllers.AccountsController.PostPrelogin (Api)'
bitwarden-api | info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
bitwarden-api | Request finished in 160.1854ms 200 application/json; charset=utf-8
bitwarden-identity | info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
bitwarden-identity | Request starting HTTP/1.0 POST http://bitwarden.example.com//identity/connect/token application/x-www-form-urlencoded 245
bitwarden-identity | info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
bitwarden-identity | Request finished in 1.3005ms 404
I guess it's notable that /accounts/prelogin
does not have a double slash, but //identity/connect/token
does. As that is the last request in the server logs, I gues rbw fails to parse its response (possibly because it's empty?).
I'm using the official bitwarden server and a traefik reverse proxy in front of that, if that matters.
ah, this is probably a difference between the official bitwarden server and bitwarden_rs (which i use). it'll probably be easiest for me to just handle the concatenation properly.
this should be fixed in 95c29fd
@doy Great, thank you!
For self-hosted servers, the
base_url
must not include a/
at the end, because/api
will be concatenated to it. If you do, the error message is quite vague:Took me some time to read your code and figure out that the slash was the problem. I was mainly confused by the example
https://api.bitwarden.com/
given, which has a trailing slash. So I included it in my self-hosted URL.Alternatively, you could think about concatenating the URL using some library, which would drop a
/
if necessary (I don't know Rust, so I can't help).Thank you for creating this tool! The
pinentry
and caching of the password in the agent is exactly what is missing from the official client.