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

Patch for pymongo.Connection to perform automatic per-socket authentication for databases after first authentication

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Major Change

      I have a proposed patch for pymongo that allows the Connection class to perform automatic per-socket authentication for databases across threads and sockets. Once a user authenticates to a database the first time in a given Connection, all future sockets created by that connection are logged-in immediately with no further action required by the user.

      This feature is intended to make it easier to efficiently use MongoDB's auth within multi-threaded web frameworks, without the need for pymongo users to preemptively authenticate connections themselves or detect and remedy exceptions caused by auth failures.

      The changeset includes unit tests that exercise the authentication in single- and multi-threaded scenarios – these tests are skipped if the local server does not have auth enabled. I have also updated the corresponding API documentation, though this needs more work.

      Pull request: http://github.com/mongodb/mongo-python-driver/pull/6

      Note that the modifications to Database.authenticate change the meaning and implications of authenticating, and so may not be backwards compatible with code that relies upon the existing per-socket-only authentication.

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            jmurty James Murty
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: