Skip to content

Multiple calls to the IDP Server(Keycloak) to fetch the token #268

Description

@ahujasagar17

Hello,

I have noticed that multiple calls to the IDP server(Keycloak) are made, I expect one call to the IDP server and the token to be shared across multiple connections, I see that the same is mentioned in the docs as well, But I am not able to achieve this.

On the client the access token is reused for multiple connections with the Kafka Broker. Before it expires the token is refreshed in the background so that a valid token is always available for all the connections. ``

Some logs:

[main] INFO org.apache.kafka.clients.consumer.internals.ConsumerCoordinator - [Consumer clientId=consumer-a_consumer-group-1, groupId=a_consumer-group] Notifying assignor about the new Assignment(partitions=[a_Topic1-0])
[main] INFO org.apache.kafka.clients.consumer.internals.ConsumerCoordinator - [Consumer clientId=consumer-a_consumer-group-1, groupId=a_consumer-group] Adding newly assigned partitions: a_Topic1-0
[main] INFO org.apache.kafka.clients.consumer.internals.ConsumerCoordinator - [Consumer clientId=consumer-a_consumer-group-1, groupId=a_consumer-group] Setting offset for partition a_Topic1-0 to the committed offset FetchPosition{offset=2, offsetEpoch=Optional[0], currentLeader=LeaderAndEpoch{leader=Optional[localhost:9093 (id: 0 rack: null)], epoch=0}}
[main] DEBUG io.strimzi.kafka.oauth.common.OAuthAuthenticator - loginWithClientSecret() - tokenEndpointUrl: https://localhost:8445/auth/realms/kafka/protocol/openid-connect/token, clientId: kafkabroker, clientSecret: Sv7ZMGDq, scope: null, audience: null, connectTimeout: 60, readTimeout: 60, retries: 0, retryPauseMillis: 0
[main] DEBUG io.strimzi.kafka.oauth.common.OAuthAuthenticator - loginWithClientSecret() - tokenEndpointUrl: https://localhost:8445/auth/realms/kafka/protocol/openid-connect/token, clientId: kafkabroker, clientSecret: Sv7Z
MGDq, scope: null, audience: null, connectTimeout: 60, readTimeout: 60, retries: 0, retryPauseMillis: 0
[main] INFO org.apache.kafka.clients.NetworkClient - [Consumer clientId=consumer-a_consumer-group-1, groupId=a_consumer-group] Node -1 disconnected.
[main] DEBUG io.strimzi.kafka.oauth.common.OAuthAuthenticator - loginWithClientSecret() - tokenEndpointUrl: https://localhost:8445/auth/realms/kafka/protocol/openid-connect/token, clientId: kafkabroker, clientSecret: Sv7ZMGDq, scope: null, audience: null, connectTimeout: 60, readTimeout: 60, retries: 0, retryPauseMillis: 0
[main] DEBUG io.strimzi.kafka.oauth.common.OAuthAuthenticator - loginWithClientSecret() - tokenEndpointUrl: https://localhost:8445/auth/realms/kafka/protocol/openid-connect/token, clientId: kafkabroker, clientSecret: Sv7Z
MGDq, scope: null, audience: null, connectTimeout: 60, readTimeout: 60, retries: 0, retryPauseMillis: 0
[main] DEBUG io.strimzi.kafka.oauth.common.OAuthAuthenticator - loginWithClientSecret() - tokenEndpointUrl: https://localhost:8445/auth/realms/kafka/protocol/openid-connect/token, clientId: kafkabroker, clientSecret: Sv7ZMGDq, scope: null, audience: null, connectTimeout: 60, readTimeout: 60, retries: 0, retryPauseMillis: 0
[main] DEBUG io.strimzi.kafka.oauth.common.OAuthAuthenticator - loginWithClientSecret() - tokenEndpointUrl: https://localhost:8445/auth/realms/kafka/protocol/openid-connect/token, clientId: kafkabroker, clientSecret: Sv7Z
MGDq, scope: null, audience: null, connectTimeout: 60, readTimeout: 60, retries: 0, retryPauseMillis: 0
[main] DEBUG io.strimzi.kafka.oauth.common.OAuthAuthenticator - loginWithClientSecret() - tokenEndpointUrl: https://localhost:8445/auth/realms/kafka/protocol/openid-connect/token, clientId: kafkabroker, clientSecret: Sv7ZMGDq, scope: null, audience: null, connectTimeout: 60, readTimeout: 60, retries: 0, retryPauseMillis: 0
[main] DEBUG io.strimzi.kafka.oauth.common.OAuthAuthenticator - loginWithClientSecret() - tokenEndpointUrl: https://localhost:8445/auth/realms/kafka/protocol/openid-connect/token, clientId: kafkabroker, clientSecret: Sv7Z
MGDq, scope: null, audience: null, connectTimeout: 60, readTimeout: 60, retries: 0, retryPauseMillis: 0

Let me know if you need more details like configurations. or a minimum working code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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