title: Mongo Query failed with error code 13 and error message 'not authorized'
body: <p>Error occures when I am trying to make an query to mongo instance on mLab. I am requesting it from spring boot app. Connection to database is stable. Below log from console.</p>
  
  <blockquote>
    <p>Monitor thread successfully connected to server with description ServerDescription{address=ds131531.mlab.com:31531, type=REPLICA_SET_PRIMARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 4, 15]}, minWireVersion=0, maxWireVersion=5, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=null, roundTripTimeNanos=138364906, setName='rs-ds131531', canonicalAddress=ds131531-a.mlab.com:31531, hosts=[ds131531-a.mlab.com:31531], passives=[], arbiters=[], primary='ds131531-a.mlab.com:31531', tagSet=TagSet{[]}, electionId=7fffffff0000000000000001, setVersion=1, lastWriteDate=Wed Jul 18 15:22:37 CEST 2018, lastUpdateTimeNanos=20828794373992}</p>
  </blockquote>
  
  <p>This is exact error message</p>
  
  <blockquote>
    <p>Query failed with error code 13 and error message 'not authorized on pizza-store to execute command { find: "product", filter: {}, batchSize: 2147483647 }' on server ds131531.mlab.com:31531; nested exception is com.mongodb.MongoQueryException: Query failed with error code 13 and error message 'not authorized on pizza-store to execute command { find: "product", filter: {}, batchSize: 2147483647 }' on server ds131531.mlab.com:31531</p>
  </blockquote>
  
  <p>If i make the same query from mongo shell everything is ok.
  I have added readWrite role and my custom readProduct role role to user who is making request but nothing is helping. dbOwner and read are builtin roles.</p>
  
  <p>Users mongo roles:</p>
  
  <pre><code>"_id" : "pizza-db.kubiakb",
  "user" : "kubiakb",
  "db" : "pizza-db",
  "roles" : [
      {
          "role" : "readProduct",
          "db" : "pizza-db"
      },
      {
          "role" : "read",
          "db" : "pizza-db"
      },
      {
          "role" : "dbOwner",
          "db" : "pizza-db"
      }
  ]
  </code></pre>
  
  <p>readProduct role</p>
  
  <pre><code>{
  "role" : "readProduct",
  "db" : "pizza-db",
  "isBuiltin" : false,
  "roles" : [ ],
  "inheritedRoles" : [ ],
  "privileges" : [
      {
          "resource" : {
              "db" : "pizza-db",
              "collection" : "product"
          },
          "actions" : [
              "find"
          ]
      }
  ],
  "inheritedPrivileges" : [
      {
          "resource" : {
              "db" : "pizza-db",
              "collection" : "product"
          },
          "actions" : [
              "find"
          ]
      }
  ]
  </code></pre>
  
  <p>}</p>
  
  <p><strong>Edit:</strong>
  Spring application.properties</p>
  
  <pre><code>spring:
    profiles: heroku
    data:
      mongodb:
        uri: mongodb://login:pass@ds131531.mlab.com:31531/pizza-db
  </code></pre>