Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-1181

Authentication is not done for DBCollection.createIndex()

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 2.12.0
    • 2.12.1
    • Authentication
    • Server: MongoDB 2.6.0

    Description

      Scenario: Run the server with auth enabled and some user created for a "foo" db. Create a MongoClient with a list of MongoCredentials (including the valid credentials for the user on "foo" db).

      Expected behavior: All connections to that db are authenticated using the credentials (as claimed by the MongoClient constructor javadoc).

      Actual behavior: While authentication is indeed done behind the scenes for most calls (like a find()), this is not true for all calls. For example, when doing the following right after creating the MongoClient, the driver does not make any authorization attempt and the client experiences an exception that the user is not authenticated to the db:
      mongoClient.getDB("foo").getCollection("bar").createIndex(new BasicDBObject("baz", 1));

      This looks like a bug to me - or is it intentional? The workaround would be to authenticate using one of the deprecated driver or to run some other command immediately after creating the client. Both are not nice.

      Looking into the code, this happens because (for example, for createIndex()) there is a path down to DBPort.call() that hasn't visited DBPort.checkAuth() before.

      Attachments

        Activity

          People

            jeff.yemin@mongodb.com Jeffrey Yemin
            patrick.peschlow@codecentric.de Patrick Peschlow
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: