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

Invalid auth mechanism is not reported until an operation is attempted on the client

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.11.0.rc0
    • Component/s: Authentication
    • Labels:
      None

      Description

      This does not produce any warnings or errors:

       
       
      client = Mongo::Client.new([ '127.0.0.1:27741' ],
                                 auth_mech: :gssapix,
                                 user: 'test',
                                 password: '123' )
      
      

      However, using this client fails:

      irb(main):024:0> client.database.command(ping:1)
      # ...
      # Traceback (most recent call last):
             16: from /home/me/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/mongo-2.7.0/lib/mongo/database.rb:172:in `block in command'
             15: from /home/me/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/mongo-2.7.0/lib/mongo/operation/shared/op_msg_or_command.rb:27:in `execute'
             14: from /home/me/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/mongo-2.7.0/lib/mongo/operation/shared/executable.rb:24:in `execute'
             13: from /home/me/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/mongo-2.7.0/lib/mongo/operation/shared/executable.rb:36:in `get_result'
             12: from /home/me/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/mongo-2.7.0/lib/mongo/operation/shared/executable.rb:41:in `dispatch_message'
             11: from /home/me/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/mongo-2.7.0/lib/mongo/server.rb:321:in `with_connection'
             10: from /home/me/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/mongo-2.7.0/lib/mongo/server/connection_pool.rb:115:in `with_connection'
              9: from /home/me/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/mongo-2.7.0/lib/mongo/operation/shared/executable.rb:42:in `block in dispatch_message'
              8: from /home/me/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/mongo-2.7.0/lib/mongo/server/connection.rb:198:in `dispatch'
              7: from /home/me/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/mongo-2.7.0/lib/mongo/server/connection.rb:254:in `deliver'
              6: from /home/me/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/mongo-2.7.0/lib/mongo/server/connectable.rb:84:in `ensure_connected'
              5: from /home/me/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/mongo-2.7.0/lib/mongo/server/connection.rb:141:in `connect!'
              4: from /home/me/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/mongo-2.7.0/lib/mongo/server/connection.rb:334:in `authenticate!'
              3: from /home/me/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/mongo-2.7.0/lib/mongo/server.rb:348:in `handle_auth_failure!'
              2: from /home/me/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/mongo-2.7.0/lib/mongo/server/connection.rb:335:in `block in authenticate!'
              1: from /home/me/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/mongo-2.7.0/lib/mongo/auth.rb:69:in `get'
      Mongo::Auth::InvalidMechanism (:gssapix is invalid, please use mongodb_cr, mongodb_x509, gssapi or plain.)
      

      The invalid mechanism should be reported during client construction probably.

      Besides invalid auth mechanisms, the driver should also abort client construction for other auth-related problems mentioned in the auth spec, such as invalid/missing auth source or properties (https://github.com/mongodb/specifications/blob/master/source/auth/auth.rst).

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              emily.giurleo Emily Giurleo
              Reporter:
              oleg.pudeyev Oleg Pudeyev
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: