dani-garcia / vaultwarden

Unofficial Bitwarden compatible server written in Rust, formerly known as bitwarden_rs
GNU Affero General Public License v3.0
38.34k stars 1.86k forks source link

1password Import is Broken #46

Closed NickBusey closed 6 years ago

NickBusey commented 6 years ago

Trying to import a 1password export (.1pif) file results in an error.

Docker logs show:

POST /api/ciphers/import application/json; charset=utf-8:
    => Matched: POST /api/ciphers/import
    => Warning: Data left unread. Force closing network stream.
    => Error: Couldn't parse JSON body: Error("EOF while parsing a string", line: 1, column: 1048576)
    => Outcome: Failure
    => Warning: Responding with 400 Bad Request catcher.
    => Error: Failed to write response: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }.
mprasil commented 6 years ago

Can you provide some file to test this? I've got a feeling that this might be limited to very specific item in the export.

dani-garcia commented 6 years ago

I think the issue here is our web server limits the size of the JSON input to 1 MB (Note how the number in column is equal to 1024 * 1024 bytes), so when an input exceeds the limit the server stops accepting more and the JSON we get is malformed.

I've increased the limit to 10 MB, which I think is probably enough, but if it isn't, you can increase it more by modifying the Rocket.toml file.

NickBusey commented 6 years ago

I can confirm it was file size. My import was 1.3MB, deleting half the contents worked.

I'm not sure the Rocket.toml is being included correctly in the docker image, or maybe I did something wrong when I tried to rebuild it. So I couldn't test your fix, but shrinking the file size worked. Thanks!

mprasil commented 6 years ago

AFAIK Rocket.toml is not included in the docker image.

But if I understand the Rocket documentation right, you should also be able to also set the limit by setting environment variable:

ROCKET_LIMITS={json=10485760}

dani-garcia commented 6 years ago

I just tested it, and what @mprasil said works. I added the rocket.toml file to the docker image anyway, so it should work now without any changes.