Skip to content

Does current version support oauthbearer/OIDC? #238

@leiwang008

Description

@leiwang008

I saw that some oauthbearer/OIDC related constants are defined in file

* Set to "default" or "oidc" to control with login method to be used.

"sasl.oauthbearer.method"
"sasl.oauthbearer.client.id"
"sasl.oauthbearer.client.secret"
"sasl.oauthbearer.scope"
"sasl.oauthbearer.token.endpoint.url"

I saw in the readme file, it says
By now, modern-cpp-kafka is compatible with librdkafka v2.4.0.
I also checked the source code of librdkafka 2.4.0, it already supports the "oauthbearer/OIDC".
So I guess that oauthbearer/OIDC is also supported in modern-cpp-kafka, right?

In the KafkaClient.h, you provide the custom callback to parse the token.

    // OAUTHBEARER Toker Refresh Callback
    if (properties.contains(Config::OAUTHBEARER_TOKEN_REFRESH_CB))
    {
        setOauthbearerTokenRefreshCallback(properties.get<OauthbearerTokenRefreshCallback>(Config::OAUTHBEARER_TOKEN_REFRESH_CB));

        rd_kafka_conf_set_oauthbearer_token_refresh_cb(rk_conf.get(), KafkaClient::oauthbearerTokenRefreshCallback);
    }

In my code, I have implemented the custom token callback to parse a json-format token something like
{"Token":"", "PrincipalName":"", "LeftTimeMS": 9999999999999, "extensions": {"a":"val", "b":"val"}} and it worked correctly with the unsecure token or with the azure-oidc token.

I would like to know if current version supports oauthbearer/OIDC? If yes, do we have any example how to use it?

From my reading, I guess that we just need to set those properties in the kafka config
"sasl.oauthbearer.method"
"sasl.oauthbearer.client.id"
"sasl.oauthbearer.client.secret"
"sasl.oauthbearer.scope"
"sasl.oauthbearer.token.endpoint.url"

and the "sasl.oauthbearer.method" should be set to "oidc" and it will work, right? The kafka-oidc implementation will override my custom token callback, right?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions