Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-5471

Incorrectly resolving the authentication mechanism parameters from SRV connection string

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 3.1.0
    • Component/s: Authentication
    • None
    • Dotnet Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      Summary

      Mongo driver is incorrectly resolving the key/value pairs of authMechanismProperties in a SRV connection string. 

      Driver version: 3.1.0

      Mongo server version: v8

      Topology: Standalone cloud cluster

      How to Reproduce

       

      public static void Process()
      {
          var text = "mongodb+srv://<cluseter>/?retryWrites=true&w=1&maxPoolSize=100&authMechanism=MONGODB-OIDC&authSource=%24external&authMechanismProperties=ENVIRONMENT:azure,prop1:user,prop2:userType";
          var mongoConnection = MongoClientSettings.FromConnectionString(text);
          Console.WriteLine(mongoConnection.Credential.GetMechanismProperty<string>("ENVIRONMENT", ""));
      // Prints "azure,prop1:user,prop2:userType" instead of just "azure"
      } 

       

      Additional Background

      Noticed this is happening because of the line of code https://github.com/mongodb/mongo-csharp-driver/blob/660f33d01fe9604044e2877e4564ce10dbfc2593/src/MongoDB.Driver/Core/Configuration/ConnectionString.cs#L909, which doesn't unescape the authMechanismProperties value(it contains the encoded values for all special characters and doesn't work well with the split happening in GetAuthMechanismProperties method) while building a resolved SRV connection string

            Assignee:
            ferdinando.papale@mongodb.com Ferdinando Papale
            Reporter:
            theepans.uk@gmail.com Theepan N/A
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              None
              None
              None
              None