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

Reduce boilerplate needed to connect using oidc from a kubernetes workload

    • Type: Icon: New Feature New Feature
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Python Drivers
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Context


      When connecting to a cluster using OIDC from a workload, unless you are using one of the supported environments, you need to write a custom callback. In fact, I believe the GCP GKE callback described in the docs is generally applicable to all Kubernetes workloads. At least, the path "/var/run/secrets/kubernetes.io/serviceaccount/token" does not appear to have anything Googly about it.

      Definition of done


      No boilerplate or custom callback should be needed for OIDC workload authentication with kubernetes service accounts. Everything should be able to live in the connection string, similar to AWS IAM role auth, where the driver will use the standard AWS credential environment variables

      Suggested syntax:
      mongodb+srv://foo.vwxyz.mongodb.net/?authSource=%24external&authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:kubernetes&retryWrites=true&w=major

      Pitfalls


      - That this is not actually a standard (could mitigate by allowing the path to be set as an optional key in authMechanismProperties)
      - That this could appear conflict with other, already supported mechanisms, that also use a file for the ID token (could alleviate by having it be a separate value for the "environment" auth mechanism property)
      - I haven't tried any of this out yet- there could be other authMechanismProperties or authentication query string options that are needed for OIDC that couldn't be known at connection string "bake" time and which would still need custom boilerplate code written to set up correctly for the MongoClient.

            Assignee:
            Unassigned Unassigned
            Reporter:
            geoff.mishkin@mongodb.com Geoffrey Mishkin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: