jcs / rubywarden

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

After upgrading db - invalid username #84

Closed shelterx closed 5 years ago

shelterx commented 5 years ago

I upgraded from bitwarden-ruby to the latest git. Now when I try to sign in i get invalid username. ` == 20180324145941 CreateUsers: migrating ====================================== -- create_table(:users, {:id=>:string, :primary_key=>:uuid}) -> 0.0038s == 20180324145941 CreateUsers: migrated (0.0040s) =============================

== 20180324151103 CreateDevices: migrating ==================================== -- create_table(:devices, {:id=>:string, :primary_key=>:uuid}) -> 0.0037s -- add_foreign_key(:devices, :users, {:column=>:user_uuid, :primary_key=>:uuid}) -> 0.0000s -- add_index(:devices, :user_uuid) -> 0.0014s == 20180324151103 CreateDevices: migrated (0.0055s) ===========================

== 20180324151113 CreateFolders: migrating ==================================== -- create_table(:folders, {:id=>:string, :primary_key=>:uuid}) -> 0.0007s -- add_foreign_key(:folders, :users, {:column=>:user_uuid, :primary_key=>:uuid}) -> 0.0000s -- add_index(:folders, :user_uuid) -> 0.0008s == 20180324151113 CreateFolders: migrated (0.0019s) ===========================

== 20180324151117 CreateCiphers: migrating ==================================== -- create_table(:ciphers, {:id=>:string, :primary_key=>:uuid}) -> 0.0011s -- add_foreign_key(:ciphers, :users, {:column=>:user_uuid, :primary_key=>:uuid}) -> 0.0000s -- add_index(:ciphers, :user_uuid) -> 0.0007s -- add_foreign_key(:ciphers, :folders, {:column=>:folder_uuid, :primary_key=>:uuid}) -> 0.0000s -- add_index(:ciphers, :folder_uuid) -> 0.0010s == 20180324151117 CreateCiphers: migrated (0.0035s) ===========================

== 20180518070354 SetDefaultValueForFavorite: migrating ======================= -- change_column_default(:ciphers, :favorite, false) -> 0.0211s -- change_column_null(:ciphers, :favorite, false, false) -> 0.0270s == 20180518070354 SetDefaultValueForFavorite: migrated (0.0485s) ==============

== 20180818095054 CreateAttachments: migrating ================================ -- remove_column(:ciphers, :attachments) -> 0.0266s -- create_table(:attachments, {:id=>:string, :primary_key=>:uuid}) -> 0.0006s -- add_foreign_key(:attachments, :ciphers, {:column=>:cipher_uuid, :primary_key=>:uuid}) -> 0.0001s -- add_index(:attachments, :cipher_uuid) -> 0.0009s == 20180818095054 CreateAttachments: migrated (0.0287s) =======================

== 20180818201731 UserKdfIterations: migrating ================================ -- add_column(:users, :kdf_iterations, :integer) -> 0.0009s == 20180818201731 UserKdfIterations: migrated (0.0035s) =======================

== 20180818212323 AddUserKdfType: migrating =================================== -- add_column(:users, :kdf_type, :integer, {:default=>0, :null=>false}) -> 0.0007s == 20180818212323 AddUserKdfType: migrated (0.0009s) ==========================

[root@dora:~/bitwarden]# env RUBYWARDEN_ENV=production bundle exec rackup -p 4567 config.ru [2018-10-24 18:00:56] INFO WEBrick 1.3.1 [2018-10-24 18:00:56] INFO ruby 2.4.4 (2018-03-28) [amd64-freebsd11] [2018-10-24 18:00:56] INFO WEBrick::HTTPServer#start: pid=59455 port=4567 D, [2018-10-24T18:01:16.522873 #59455] DEBUG -- : User Load (0.3ms) SELECT "users". FROM "users" WHERE "users"."email" = ? LIMIT ? [["email", "foo@bar.net"], ["LIMIT", 1]] 192.168.100.1 - - [24/Oct/2018:18:01:16 +0200] "POST /api/accounts/prelogin HTTP/1.1" 200 30 0.0389 D, [2018-10-24T18:01:16.587990 #59455] DEBUG -- : User Load (0.2ms) SELECT "users". FROM "users" WHERE "users"."email" = ? LIMIT ? [["email", "foo@bar.net"], ["LIMIT", 1]] 192.168.100.1 - - [24/Oct/2018:18:01:16 +0200] "POST /identity/connect/token HTTP/1.1" 400 63 0.0073 D, [2018-10-24T18:02:27.732496 #59455] DEBUG -- : User Load (0.2ms) SELECT "users". FROM "users" WHERE "users"."email" = ? LIMIT ? [["email", "foo@bar.net"], ["LIMIT", 1]] 192.168.100.1 - - [24/Oct/2018:18:02:27 +0200] "POST /api/accounts/prelogin HTTP/1.1" 200 30 0.0020 D, [2018-10-24T18:02:27.775818 #59455] DEBUG -- : User Load (0.2ms) SELECT "users". FROM "users" WHERE "users"."email" = ? LIMIT ? [["email", "foo@bar.net"], ["LIMIT", 1]] 192.168.100.1 - - [24/Oct/2018:18:02:27 +0200] "POST /identity/connect/token HTTP/1.1" 400 63 0.0019 `

shelterx commented 5 years ago

iPhone app works now. Firefox extension does not. This is what happens if i sign in: [2018-10-24T21:17:56.911868 #59953] DEBUG -- : User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT ? [["email", "rickard@refused.net"], ["LIMIT", 1]] 2018-10-24 21:17:56 - NoMethodError - undefined method kdf_iterations' for #<User:0x0000000808e524e0>: /usr/local/lib/ruby/gems/2.4/gems/activemodel-5.1.6/lib/active_model/attribute_methods.rb:432:inmethod_missing' /root/rubywarden/lib/routes/api.rb:31:in block (2 levels) in registered' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:1635:incall' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:1635:in block in compile!' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:992:inblock (3 levels) in route!' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:1011:in route_eval' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:992:inblock (2 levels) in route!' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:1040:in block in process_route' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:1038:incatch' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:1038:in process_route' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:990:inblock in route!' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:989:in each' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:989:inroute!' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:1097:in block in dispatch!' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:1076:inblock in invoke' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:1076:in catch' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:1076:ininvoke' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:1094:in dispatch!' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:924:inblock in call!' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:1076:in block in invoke' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:1076:incatch' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:1076:in invoke' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:924:incall!' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:913:in call' /usr/local/lib/ruby/gems/2.4/gems/rack-protection-2.0.3/lib/rack/protection/xss_header.rb:18:incall' /usr/local/lib/ruby/gems/2.4/gems/rack-protection-2.0.3/lib/rack/protection/path_traversal.rb:16:in call' /usr/local/lib/ruby/gems/2.4/gems/rack-protection-2.0.3/lib/rack/protection/json_csrf.rb:26:incall' /usr/local/lib/ruby/gems/2.4/gems/rack-protection-2.0.3/lib/rack/protection/base.rb:50:in call' /usr/local/lib/ruby/gems/2.4/gems/rack-protection-2.0.3/lib/rack/protection/base.rb:50:incall' /usr/local/lib/ruby/gems/2.4/gems/rack-protection-2.0.3/lib/rack/protection/frame_options.rb:31:in call' /usr/local/lib/ruby/gems/2.4/gems/rack-2.0.5/lib/rack/logger.rb:15:incall' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:224:in call' /usr/local/lib/ruby/gems/2.4/gems/rack-2.0.5/lib/rack/head.rb:12:incall' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:194:in call' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:1958:incall' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:1502:in block in call' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:1729:insynchronize' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:1502:in call' /usr/local/lib/ruby/gems/2.4/gems/rack-2.0.5/lib/rack/tempfile_reaper.rb:15:incall' /usr/local/lib/ruby/gems/2.4/gems/rack-2.0.5/lib/rack/common_logger.rb:33:in call' /usr/local/lib/ruby/gems/2.4/gems/sinatra-2.0.3/lib/sinatra/base.rb:231:incall' /usr/local/lib/ruby/gems/2.4/gems/rack-2.0.5/lib/rack/chunked.rb:54:in call' /usr/local/lib/ruby/gems/2.4/gems/rack-2.0.5/lib/rack/content_length.rb:15:incall' /usr/local/lib/ruby/gems/2.4/gems/rack-2.0.5/lib/rack/handler/webrick.rb:86:in service' /usr/local/lib/ruby/2.4/webrick/httpserver.rb:140:inservice' /usr/local/lib/ruby/2.4/webrick/httpserver.rb:96:in run' /usr/local/lib/ruby/2.4/webrick/server.rb:308:inblock in start_thread' 192.168.100.1 - - [24/Oct/2018:21:17:56 +0200] "POST /api/accounts/prelogin HTTP/1.1" 500 30 0.0033

shelterx commented 5 years ago

Ahem, this one was a bit tricky. I missed the migrate to AR part because I thought that's what "env RUBYWARDEN_ENV=production bundle exec rake db:migrate" did. So I did this migrate and first it created an empty database (maybe you could include some check here to see if there's an actual DB that can be updated) Somehow I got the migrate to work with the iPhone app, don't ask me how.

Maybe you should make the migrate to AR link a bit more visible on github, I didn't see it. I found out by reading AR-MIGRATE.md in the rubywarden folder.