Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-920

Specifying a database name in URI other than admin triggers authentication

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.0.0
    • Component/s: Authentication
    • None

      Connecting using URI as below:

      mongoURI := "mongodb://localhost:27017/test"
      client, err := mongo.NewClient(options.Client().ApplyURI(mongoURI))
      

      Generates application error:

      2019/04/02 15:39:52 auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-1": (AuthenticationFailed) Authentication failed.
      exit status 1
      

      MongoDB (v4.0.8) server log error:

      2019-04-02T15:39:52.728+1100 I NETWORK  [conn105] received client metadata from 127.0.0.1:54219 conn105: { driver: { name: "mongo-go-driver", version: "v1.0.0" }, os: { type: "darwin", architecture: "amd64" }, platform: "go1.11.5" }
      2019-04-02T15:39:52.728+1100 I ACCESS   [conn105] Supported SASL mechanisms requested for unknown user '@test'
      2019-04-02T15:39:52.728+1100 I ACCESS   [conn105] SASL SCRAM-SHA-1 authentication failed for  on test from client 127.0.0.1:54219 ; BadValue: Invalid SCRAM user name: n=
      

      Changing the URI to any of the below works:

      mongoURI := "mongodb://localhost:27017"
      mongoURI := "mongodb://localhost:27017/admin"
      mongoURI := "mongodb://localhost:27017/?authSource=admin"
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            wan.bachtiar@mongodb.com Wan Bachtiar
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: