OIDC username not passed to custom callback

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.2.0
    • Component/s: None
    • None
    • Not Needed
    • None
    • C Drivers
    • Not Needed
    • 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?
    • 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: