Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-890

Unauthorized error occures to connect mongos except an admin user

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.0.3
    • Affects Version/s: 2.0.2
    • Component/s: Auth
    • Environment:
      CentOS 6.4
      Ruby 1.2.1
      MongoDB 3.0.1 (authentication mechanism : SCRAM-SHA-1)

      "Unauthorized User" error occures when retrieving a collection with a 'dbOwner' user.
      The following code runs correctly, if an admin user is specified in Mongo::Client.new option,

      1. Ruby Code
        require 'mongo'
        > db = Mongo::Client.new(
        ['test-server:20001'],
        :connect => :sharded,
        :database => "test",
        :user => "test_user", # run correctly if :user => "admin_user"
        :password => "test_pass")
        > db["test_col"].find.count

      Mongo::Auth::Unauthorized: User test_user is not authorized to access test.
      from /home/dep/.rvm/gems/ruby-2.1.2/gems/mongo-2.0.2/lib/mongo/auth/scram/conversation.rb:445:in `validate!'
      from /home/dep/.rvm/gems/ruby-2.1.2/gems/mongo-2.0.2/lib/mongo/auth/scram/conversation.rb:440:in `validate_first_message!'
      from /home/dep/.rvm/gems/ruby-2.1.2/gems/mongo-2.0.2/lib/mongo/auth/scram/conversation.rb:112:in `continue'
      from /home/dep/.rvm/gems/ruby-2.1.2/gems/mongo-2.0.2/lib/mongo/auth/scram.rb:45:in `login'
      from /home/dep/.rvm/gems/ruby-2.1.2/gems/mongo-2.0.2/lib/mongo/server/connection.rb:64:in `connect!'
      from /home/dep/.rvm/gems/ruby-2.1.2/gems/mongo-2.0.2/lib/mongo/server/connectable.rb:89:in `ensure_connected'
      from /home/dep/.rvm/gems/ruby-2.1.2/gems/mongo-2.0.2/lib/mongo/server/connection.rb:130:in `write'
      from /home/dep/.rvm/gems/ruby-2.1.2/gems/mongo-2.0.2/lib/mongo/server/connectable.rb:66:in `block in dispatch'
      from /home/dep/.rvm/gems/ruby-2.1.2/gems/mongo-2.0.2/lib/mongo/loggable.rb:44:in `log'
      from /home/dep/.rvm/gems/ruby-2.1.2/gems/mongo-2.0.2/lib/mongo/loggable.rb:65:in `log_debug'
      from /home/dep/.rvm/gems/ruby-2.1.2/gems/mongo-2.0.2/lib/mongo/server/connectable.rb:65:in `dispatch'
      from /home/dep/.rvm/gems/ruby-2.1.2/gems/mongo-2.0.2/lib/mongo/operation/command.rb:51:in `block in execute'
      from /home/dep/.rvm/gems/ruby-2.1.2/gems/mongo-2.0.2/lib/mongo/server/connection_pool.rb:99:in `with_connection'
      from /home/dep/.rvm/gems/ruby-2.1.2/gems/mongo-2.0.2/lib/mongo/server/context.rb:62:in `with_connection'
      from /home/dep/.rvm/gems/ruby-2.1.2/gems/mongo-2.0.2/lib/mongo/operation/command.rb:50:in `execute'
      from /home/dep/.rvm/gems/ruby-2.1.2/gems/mongo-2.0.2/lib/mongo/database.rb:136:in `command'
      from /home/dep/.rvm/gems/ruby-2.1.2/gems/mongo-2.0.2/lib/mongo/collection/view/readable.rb:124:in `count'
      :

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            incredible_hana Onari Tanaka
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: