{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/3484","labels_url":"https://api.github.com/repos/Automattic/mongoose/issues/3484/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/mongoose/issues/3484/comments","events_url":"https://api.github.com/repos/Automattic/mongoose/issues/3484/events","html_url":"https://github.com/Automattic/mongoose/issues/3484","id":112482622,"number":3484,"title":"Connect options no longer accept user & pass as empty strings","user":{"login":"mleanos","id":5613734,"avatar_url":"https://avatars.githubusercontent.com/u/5613734?v=3","gravatar_id":"","url":"https://api.github.com/users/mleanos","html_url":"https://github.com/mleanos","followers_url":"https://api.github.com/users/mleanos/followers","following_url":"https://api.github.com/users/mleanos/following{/other_user}","gists_url":"https://api.github.com/users/mleanos/gists{/gist_id}","starred_url":"https://api.github.com/users/mleanos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mleanos/subscriptions","organizations_url":"https://api.github.com/users/mleanos/orgs","repos_url":"https://api.github.com/users/mleanos/repos","events_url":"https://api.github.com/users/mleanos/events{/privacy}","received_events_url":"https://api.github.com/users/mleanos/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/Automattic/mongoose/milestones/66","html_url":"https://github.com/Automattic/mongoose/milestones/4.2.3","labels_url":"https://api.github.com/repos/Automattic/mongoose/milestones/66/labels","id":1350847,"number":66,"title":"4.2.3","description":"","creator":{"login":"vkarpov15","id":1620265,"avatar_url":"https://avatars.githubusercontent.com/u/1620265?v=3","gravatar_id":"","url":"https://api.github.com/users/vkarpov15","html_url":"https://github.com/vkarpov15","followers_url":"https://api.github.com/users/vkarpov15/followers","following_url":"https://api.github.com/users/vkarpov15/following{/other_user}","gists_url":"https://api.github.com/users/vkarpov15/gists{/gist_id}","starred_url":"https://api.github.com/users/vkarpov15/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkarpov15/subscriptions","organizations_url":"https://api.github.com/users/vkarpov15/orgs","repos_url":"https://api.github.com/users/vkarpov15/repos","events_url":"https://api.github.com/users/vkarpov15/events{/privacy}","received_events_url":"https://api.github.com/users/vkarpov15/received_events","type":"User","site_admin":false},"open_issues":15,"closed_issues":8,"state":"open","created_at":"2015-10-12T13:26:39Z","updated_at":"2015-10-24T16:40:47Z","due_on":"2015-10-26T04:00:00Z","closed_at":null},"comments":4,"created_at":"2015-10-20T23:42:59Z","updated_at":"2015-10-24T20:44:51Z","closed_at":"2015-10-24T16:40:47Z","body":"Previously, in version `4.1.11` I was able to pass the `user` and `pass` options into the `connect` method as empty strings. Like so..\r\n```javascript\r\nvar db = mongoose.connect('mongodb://localhost/dev', { user: '', pass: '' }, function (err) {\r\n  if (err) {\r\n    console.log(err);\r\n  } else {\r\n    console.log('connected');\r\n  }\r\n});\r\n```\r\nHowever, in version `4.1.12`, this no longer works. I get a `auth failed` error. I have verified that there's a difference in the way the authentication is handling the `user` and `pass` between the two versions of this library.\r\n\r\n```javascript\r\n// from 4.1.11\r\n// test passes\r\nit('including user/pass as empty strings', function(done) {\r\n      var db = mongoose.createConnection('localhost', 'fake', 27000, {user: '', pass: ''});\r\n      db.on('error', function() {});\r\n      assert.equal('object', typeof db.options);\r\n      assert.equal('object', typeof db.options.server);\r\n      assert.equal(true, db.options.server.auto_reconnect);\r\n      assert.equal('object', typeof db.options.db);\r\n      assert.equal(false, db.options.db.forceServerObjectId);\r\n      assert.equal('fake', db.name);\r\n      assert.equal('localhost', db.host);\r\n      assert.equal(27000, db.port);\r\n      assert.equal(undefined, db.pass);\r\n      assert.equal(undefined, db.user);\r\n      db.close();\r\n      done();\r\n    });\r\n\r\n// from 4.1.12\r\n// test fails on the db.shouldAuthenticate() assertion. \r\ndescribe('when username and password are empty strings', function() {\r\n        it('should return false', function(done) {\r\n          var db = mongoose.createConnection('localhost', 'fake', 27000, { user: '', pass: ''});\r\n          db.on('error', function() {});\r\n          assert.equal('object', typeof db.options);\r\n          assert.equal('object', typeof db.options.server);\r\n          assert.equal(true, db.options.server.auto_reconnect);\r\n          assert.equal('object', typeof db.options.db);\r\n          assert.equal(false, db.options.db.forceServerObjectId);\r\n          assert.equal('fake', db.name);\r\n          assert.equal('localhost', db.host);\r\n          assert.equal(27000, db.port);\r\n          assert.equal('', db.pass);\r\n          assert.equal('', db.user);\r\n\r\n          assert.equal(false, db.shouldAuthenticate()); // db.shouldAuthenticate() returns true\r\n\r\n          db.close();\r\n          done();\r\n        });\r\n      });\r\n```\r\n\r\nIf you notice that in `4.1.11` the `user` and `pass` options are passed back as undefined. This tells me that they are being deliberately handled & bypassed by the authentication. `4.1.12` doesn't handle them the same. They are passed back as their original empty strings.\r\n\r\nIs the behavior in `4.1.12` a bug, or does it fix a previous bug? Or perhaps this is just a purposed change in the way authentication is treating use cases as this.\r\n"},"comment":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/comments/150849537","html_url":"https://github.com/Automattic/mongoose/issues/3484#issuecomment-150849537","issue_url":"https://api.github.com/repos/Automattic/mongoose/issues/3484","id":150849537,"user":{"login":"mleanos","id":5613734,"avatar_url":"https://avatars.githubusercontent.com/u/5613734?v=3","gravatar_id":"","url":"https://api.github.com/users/mleanos","html_url":"https://github.com/mleanos","followers_url":"https://api.github.com/users/mleanos/followers","following_url":"https://api.github.com/users/mleanos/following{/other_user}","gists_url":"https://api.github.com/users/mleanos/gists{/gist_id}","starred_url":"https://api.github.com/users/mleanos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mleanos/subscriptions","organizations_url":"https://api.github.com/users/mleanos/orgs","repos_url":"https://api.github.com/users/mleanos/repos","events_url":"https://api.github.com/users/mleanos/events{/privacy}","received_events_url":"https://api.github.com/users/mleanos/received_events","type":"User","site_admin":false},"created_at":"2015-10-24T20:44:51Z","updated_at":"2015-10-24T20:44:51Z","body":"@vkarpov15 You're welcome! It was my pleasure.\r\n\r\nWhen can we expect this to be released? Since `4.2.1` was already released.\r\n"}}