jcs / rubywarden

An unofficial, mostly Bitwarden-compatible API server written in Ruby (Sinatra and ActiveRecord)
ISC License
593 stars 49 forks source link

Some identity fields are not saved #53

Closed MrClayPole closed 5 years ago

MrClayPole commented 6 years ago

Version 1.2.0 Shell 1.8.4 Renderer 59.0.3071.115 Node 8.2.1 Architecture x64 OS Windows 10 Pro x64

When creating a new identity and hit save the follow fields are not saved: First Name, Middle Name, Last Name, Social Security Number, Passport Number, License Number & Post Code. If I edit the entry they are not visable and if I enter them again and hit save they are also not saved.

universal commented 6 years ago

Hello can you check if it works if you apply #47 ? This might fix this!

MrClayPole commented 6 years ago

Thanks for the patch. I've manually patched the lib/helper.rb file as per the commit and its now working.

MrClayPole commented 6 years ago

Spoke to soon. Looks like it now saves every field apart from "Social Security Number"

universal commented 6 years ago

i just checked the web-vault code, and it looks like for the other fields it looks for posted-name with first letter upcased, but for SSN it wants all letters upcased, so right now the code generates Ssn, but it wants SSN.

The chrome addon sends "ssn" as the parameter name, I'll cross-check with the web-vault and maybe one needs to special case ssn... :(

edith says: yep, the web-vault sends the keys in a different format, then it expects them back... :( no clue why this is, maybe because of historical reasons...

And changing the helper to this, solves this problem. It probably makes more sense to move this in an app specific helper like: BitwardenRuby::convert_params(p)

class Sinatra::IndifferentHash
  def ucfirst_hash
    out = {}
    self.each do |k,v|
      base = k.to_s
      out[base == "ssn" ? "SSN" : base.ucfirst] = v
    end
    out
  end
end
universal commented 6 years ago

note to myself: need to cross-check with the new web-vault if anything in parameter handling changed there.