Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-860

GridFS.list and other operations fail as read-only user

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.1
    • Affects Version/s: None
    • Component/s: None
    • None

      GridFS ensures two indexes before doing some operations. It tries to avoid calling createIndex on a secondary, but doesn't recover if it gets a "not authorized" error.

      This needs a drivers-wide spec, eventually part of the GridFS Spec. It may be reasonable to catch OperationFailure and ignore it for "not authorized" or the appropriate error codes.

      class TestGridfsAuth(IntegrationTest):
      
          @client_context.require_auth
          def test_gridfs_readonly(self):
              # "self.client" is logged in as root. Make a read-only user.
              auth_db = self.client.test_gridfs_readonly
              auth_db.add_user('readonly', 'pw', roles=['read'])
              self.addCleanup(remove_all_users, auth_db)
      
              db = rs_or_single_client_noauth().test_gridfs_readonly
              db.authenticate('readonly', 'pw')
              gridfs.GridFS(db).list()
      

            Assignee:
            anna.herlihy@mongodb.com Anna Herlihy (Inactive)
            Reporter:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: