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

OIDC Credentials doesn't get refreshed past expiry

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Critical - P2 Critical - P2
    • None
    • Affects Version/s: 2.7.0, 3.0.0
    • Component/s: Authentication
    • Dotnet 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?

      Summary

      When using the IOIDCCallback interface, the returned OidcAccessToken is never refreshed, no matter what you assign to the expiresIn property. The consequence is that the token will eventually expire but will never be refreshed. Specifically, the GetOidcAccessToken or the GetOidcAccessTokenAsync methods that you need to implement from the IOidcCallback interface is only called once and never again.

      Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

      c# driver version 2.7 & 3.0 (we havent tested more versions)

      How to Reproduce

      1. Implement the IOidcCallback interface
      2. Create a MongoClient
      3. Use MongoCredential.CreateOidcCredential with the concrete implementation of the IOidcCallback interface to assign the credential. 
      4. In a loop, query the database/collection for a document, doesn't matter what.
      5. Eventually, the access token will expire because the GetOidcAccessToken wont ever be called again.

      Additional Background

      none provided

        1. image-2024-10-28-12-44-12-041.png
          195 kB
          Oleksandr Poliakov
        2. image-2024-10-28-13-22-20-485.png
          130 kB
          Nicolas Ducharme
        3. image-2024-10-28-13-29-02-095.png
          77 kB
          Nicolas Ducharme
        4. image-2024-10-28-13-38-58-702.png
          15 kB
          Nicolas Ducharme
        5. MongoCommandException.txt
          15 kB
          Nicolas Ducharme
        6. Program.cs
          2 kB
          Nicolas Ducharme

            Assignee:
            oleksandr.poliakov@mongodb.com Oleksandr Poliakov
            Reporter:
            nducharme@genetec.com Nicolas Ducharme
            Votes:
            7 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: