OIDC username not passed to custom callback

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 2.3.1
    • Affects Version/s: 2.2.0
    • Component/s: None
    • None
    • Not Needed
    • None
    • C Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      Summary

      Custom OIDC callback does not set username parameter when one is passed.

      To reproduce

      #include <assert.h>
      #include <mongoc/mongoc.h>
      
      static mongoc_oidc_credential_t *
      oidc_fn(mongoc_oidc_callback_params_t *params) {
        const char *got = mongoc_oidc_callback_params_get_username(params);
        assert(got && 0 == strcmp(got, "user")); // Fails!
        return NULL;
      }
      
      int main() {
        mongoc_init();
      
        mongoc_client_t *client = mongoc_client_new(
            "mongodb://user@localhost:27017/?authMechanism=MONGODB-OIDC");
        mongoc_oidc_callback_t *cb = mongoc_oidc_callback_new(oidc_fn);
        mongoc_client_set_oidc_callback(client, cb);
        bson_t *ping = BCON_NEW("ping", BCON_INT32(1));
        mongoc_client_command_simple(client, "admin", ping, NULL, NULL, NULL);
        bson_destroy(ping);
        mongoc_oidc_callback_destroy(cb);
        mongoc_client_destroy(client);
        mongoc_cleanup();
      }
      

            Assignee:
            Kevin Albertson
            Reporter:
            Kevin Albertson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: