I've been trying to import some Bitwarden JSON containing TOTP information into KeePass, and I noticed that it appears to just create a custom field called TOTP, instead of importing the TOTP information into the separate fields that KeePass expects. As such, it's not possible to generate TOTP codes from the imported entries.
I've had a look at the code and I've come up with a simple patch to the ImportLogin method in BitwardenJson112.cs. The new code checks to see if the TOTP data being imported is an otpauth:// URL, and if it is, it uses the ImportOtpAuth method instead to ensure that it gets imported correctly.
If the TOTP field does not look like an otpauth:// URL, the old code path is followed to allow importing information in any other format (although all the Bitwarden JSON examples I've seen seem to expect an otpauth:// URL in this field).
Hopefully you can include this patch (or a similar fix) in a future release.
Thanks
privatestaticvoidImportLogin(JsonObjectjo,PwEntrype,PwDatabasepd){ImportString(jo,"username",pe,PwDefs.UserNameField,pd);ImportString(jo,"password",pe,PwDefs.PasswordField,pd);// START OF PATCHstringtotpURL=jo.GetValue<string>("totp");if(totpURL!=null&&totpURL.StartsWith("otpauth:")){// Import URL into multiple fields so that TOTP codes can be generatedEntryUtil.ImportOtpAuth(pe,totpURL,pd);}else{// Existing behaviourImportString(jo,"totp",pe,"TOTP",pd);ProtectedStringps=pe.Strings.Get("TOTP");if(ps!=null)pe.Strings.Set("TOTP",ps.WithProtection(true));}// END OF PATCHJsonObject[]vUris=jo.GetValueArray<JsonObject>("uris");if(vUris!=null){intiUri=1;foreach(JsonObjectjoUriinvUris){if(joUri==null){Debug.Assert(false);continue;}stringstr=joUri.GetValue<string>("uri");if(!string.IsNullOrEmpty(str)){ImportUtil.AppendToField(pe,((iUri==1)?PwDefs.UrlField:("URL "+iUri.ToString())),str,pd);++iUri;}}}}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I already have the information in the Bitwarden JSON file format, the trouble is that KeePass doesn't import this into the right fields (TimeOtp-*). The patch I provided above can be applied to KeePass to resolve the issue.
Hi there
I've been trying to import some Bitwarden JSON containing TOTP information into KeePass, and I noticed that it appears to just create a custom field called
TOTP
, instead of importing the TOTP information into the separate fields that KeePass expects. As such, it's not possible to generate TOTP codes from the imported entries.I've had a look at the code and I've come up with a simple patch to the
ImportLogin
method inBitwardenJson112.cs
. The new code checks to see if the TOTP data being imported is anotpauth://
URL, and if it is, it uses theImportOtpAuth
method instead to ensure that it gets imported correctly.If the TOTP field does not look like an
otpauth://
URL, the old code path is followed to allow importing information in any other format (although all the Bitwarden JSON examples I've seen seem to expect anotpauth://
URL in this field).Hopefully you can include this patch (or a similar fix) in a future release.
Thanks
I would say first you should contact Bitwarden about what your asking as well.
https://bitwarden.com/help/authenticator-keys/
No, I don't think that's helpful.
I already have the information in the Bitwarden JSON file format, the trouble is that KeePass doesn't import this into the right fields (
TimeOtp-*
). The patch I provided above can be applied to KeePass to resolve the issue.You can find information about the Bitwarden JSON file format including a link to a sample file at https://bitwarden.com/help/condition-bitwarden-import/#condition-a-json
The
totp
field in that file already contains the information that I'm interested in.Thanks for the hint! I've now added such an automatic conversion (similar to what you suggested).
Here's the latest development snapshot for testing:
https://keepass.info/filepool/KeePass_220703.zip
Best regards,
Dominik
Thanks @dreichl, that snapshot build works the way I was expecting.