Skip to content

Make Java Client Authentication Asynchronous #19429

Closed

Description

@michaeljmarshall

Search before asking

  • I searched in the issues and found nothing similar.

Motivation

The OAuth2 client's authenticate call is blocking, which is not great for the client, and is bad for the proxy because the proxy authenticates from a netty event loop.

Solution

In the same way that PIP 97 #12105 make the AuthenticationProvider async, we should update the Authentication interface.

Alternatives

No response

Anything else?

This change will likely require a PIP. I am unable to write such a PIP at this time, so I am creating this issue to keep track of this missing feature.

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Activity

  1. added
    type/enhancement
    on Feb 5, 2023
  2. github-actions commented on Mar 16, 2023

    @github-actions

    The issue had no activity for 30 days, mark with Stale label.

  3. added
    good first issue
    and removed on Mar 21, 2023
  4. tisonkun commented on Mar 21, 2023

    @tisonkun
    Member

    @michaeljmarshall shall we make a PIP for this enhancement?

  5. michaeljmarshall commented on Mar 21, 2023

    @michaeljmarshall
    MemberAuthor

    We could make a PIP, though I don't have time to work on it right now.

  6. Abhijeetmishr commented on Apr 15, 2023

    @Abhijeetmishr

    @michaeljmarshall @tisonkun can I pick this up ?

  7. tisonkun commented on Apr 15, 2023

    @tisonkun
    Member

    @Abhijeetmishr assigned. Go ahead!

    May I ask what's your plan to handle this issue?

  8. Abhijeetmishr commented on Apr 15, 2023

    @Abhijeetmishr

    @Abhijeetmishr assigned. Go ahead!

    May I ask what's your plan to handle this issue?

    Hey @tisonkun Thank you for assigning.
    I think this will be achieved using Java Completetable future.
    we have to update the interfaces such as AuthenticationProvider, AuthenticationState, and AuthenticationDataSource.
    I am not sure about the module. I need little clarification to get started asap.

    Regards,
    Abhijeet

  9. github-actions commented on May 16, 2023

    @github-actions

    The issue had no activity for 30 days, mark with Stale label.

  10. arsenalzp commented on Nov 15, 2023

    @arsenalzp

    Any progress with this issue?

  11. AbhinavAtul commented on Dec 6, 2023

    @AbhinavAtul

    Hi, when trying async lastDisconnectedTimestamp is no longer zero. As a result, ProxyRefreshAuthTest fails (expects lastDisconnectedTimestamp to be zero). If any, what would be an acceptable max disconnect-reconnect interval that could be used as litmus for the test? Disconnect-reconnect log inline

    2023-12-06T06:42:04,556 - INFO  - [pulsar-client-io-44-3:ConnectionPool@270] - [[id: 0x27a867ef, L:/127.0.0.1:45060 - R:************/127.0.1.1:39725]] Connected to server
    2023-12-06T06:42:04,647 - INFO  - [pulsar-proxy-io-42-5:ConnectionPool@270] - [[id: 0x30bb7cae, L:/127.0.0.1:57236 - R:************/127.0.1.1:34547]] Connected to server
    2023-12-06T06:42:04,700 - INFO  - [pulsar-io-8-1:ServerCnx@731] - [/127.0.0.1:57236] connected role=Proxy and originalAuthRole=client using authMethod=token, clientVersion=Pulsar-Java-v3.2.0-SNAPSHOT, clientProtocolVersion=21, proxyVersion=3.2.0-SNAPSHOT
    2023-12-06T06:42:06,690 - INFO  - [pulsar-proxy-io-42-5:ClientCnx@347] - [id: 0x30bb7cae, L:/127.0.0.1:57236 ! R:************/127.0.1.1:34547] Disconnected
    2023-12-06T06:42:06,746 - INFO  - [pulsar-proxy-io-42-7:ConnectionPool@270] - [[id: 0x0acdfa58, L:/127.0.0.1:57238 - R:************/127.0.1.1:34547]] Connected to server
    2023-12-06T06:42:06,753 - INFO  - [pulsar-io-8-2:ServerCnx@731] - [/127.0.0.1:57238] connected role=Proxy and originalAuthRole=client using authMethod=token, clientVersion=Pulsar-Java-v3.2.0-SNAPSHOT, clientProtocolVersion=21, proxyVersion=3.2.0-SNAPSHOT
    2023-12-06T06:42:07,641 - INFO  - [pulsar-client-io-44-3:ClientCnx@347] - [id: 0x27a867ef, L:/127.0.0.1:45060 ! R:************/127.0.1.1:39725] Disconnected
    2023-12-06T06:42:07,653 - INFO  - [pulsar-proxy-io-42-7:ClientCnx@347] - [id: 0x0acdfa58, L:/127.0.0.1:57238 ! R:************/127.0.1.1:34547] Disconnected
    2023-12-06T06:42:07,738 - INFO  - [pulsar-client-io-44-5:ConnectionPool@270] - [[id: 0x812e0999, L:/127.0.0.1:45062 - R:************/127.0.1.1:39725]] Connected to server
    2023-12-06T06:42:07,758 - INFO  - [pulsar-proxy-io-42-12:ConnectionPool@270] - [[id: 0x5b59280a, L:/127.0.0.1:57240 - R:************/127.0.1.1:34547]] Connected to server
    2023-12-06T06:42:07,765 - INFO  - [pulsar-io-8-3:ServerCnx@731] - [/127.0.0.1:57240] connected role=Proxy and originalAuthRole=client using authMethod=token, clientVersion=Pulsar-Java-v3.2.0-SNAPSHOT, clientProtocolVersion=21, proxyVersion=3.2.0-SNAPSHOT
    2023-12-06T06:42:09,767 - INFO  - [pulsar-proxy-io-42-12:ClientCnx@347] - [id: 0x5b59280a, L:/127.0.0.1:57240 ! R:************/127.0.1.1:34547] Disconnected
    2023-12-06T06:42:09,863 - INFO  - [pulsar-proxy-io-42-14:ConnectionPool@270] - [[id: 0x385fd2e9, L:/127.0.0.1:57254 - R:************/127.0.1.1:34547]] Connected to server
    2023-12-06T06:42:09,871 - INFO  - [pulsar-io-8-4:ServerCnx@731] - [/127.0.0.1:57254] connected role=Proxy and originalAuthRole=client using authMethod=token, clientVersion=Pulsar-Java-v3.2.0-SNAPSHOT, clientProtocolVersion=21, proxyVersion=3.2.0-SNAPSHOT
    2023-12-06T06:42:10,753 - INFO  - [pulsar-client-io-44-5:ClientCnx@347] - [id: 0x812e0999, L:/127.0.0.1:45062 ! R:************/127.0.1.1:39725] Disconnected
    2023-12-06T06:42:10,755 - INFO  - [pulsar-proxy-io-42-14:ClientCnx@347] - [id: 0x385fd2e9, L:/127.0.0.1:57254 ! R:************/127.0.1.1:34547] Disconnected
    2023-12-06T06:42:10,855 - INFO  - [pulsar-client-io-44-7:ConnectionPool@270] - [[id: 0x330b9cb9, L:/127.0.0.1:45072 - R:************/127.0.1.1:39725]] Connected to server
    2023-12-06T06:42:10,875 - INFO  - [pulsar-proxy-io-42-19:ConnectionPool@270] - [[id: 0xcfedf2eb, L:/127.0.0.1:57266 - R:************/127.0.1.1:34547]] Connected to server
    2023-12-06T06:42:10,878 - INFO  - [pulsar-io-8-1:ServerCnx@731] - [/127.0.0.1:57266] connected role=Proxy and originalAuthRole=client using authMethod=token, clientVersion=Pulsar-Java-v3.2.0-SNAPSHOT, clientProtocolVersion=21, proxyVersion=3.2.0-SNAPSHOT
    2023-12-06T06:42:12,882 - INFO  - [pulsar-proxy-io-42-19:ClientCnx@347] - [id: 0xcfedf2eb, L:/127.0.0.1:57266 ! R:************/127.0.1.1:34547] Disconnected
    2023-12-06T06:42:12,941 - INFO  - [pulsar-proxy-io-42-21:ConnectionPool@270] - [[id: 0x026b593c, L:/127.0.0.1:44420 - R:************/127.0.1.1:34547]] Connected to server
    2023-12-06T06:42:12,945 - INFO  - [pulsar-io-8-2:ServerCnx@731] - [/127.0.0.1:44420] connected role=Proxy and originalAuthRole=client using authMethod=token, clientVersion=Pulsar-Java-v3.2.0-SNAPSHOT, clientProtocolVersion=21, proxyVersion=3.2.0-SNAPSHOT
    2023-12-06T06:42:13,873 - INFO  - [pulsar-client-io-44-7:ClientCnx@347] - [id: 0x330b9cb9, L:/127.0.0.1:45072 ! R:************/127.0.1.1:39725] Disconnected
    2023-12-06T06:42:13,875 - INFO  - [pulsar-proxy-io-42-21:ClientCnx@347] - [id: 0x026b593c, L:/127.0.0.1:44420 ! R:************/127.0.1.1:34547] Disconnected
    2023-12-06T06:42:13,917 - INFO  - [pulsar-client-io-44-9:ConnectionPool@270] - [[id: 0xadfa256c, L:/127.0.0.1:48706 - R:************/127.0.1.1:39725]] Connected to server
    2023-12-06T06:42:13,936 - INFO  - [pulsar-proxy-io-42-26:ConnectionPool@270] - [[id: 0x14c0d475, L:/127.0.0.1:44430 - R:************/127.0.1.1:34547]] Connected to server
    2023-12-06T06:42:13,939 - INFO  - [pulsar-io-8-3:ServerCnx@731] - [/127.0.0.1:44430] connected role=Proxy and originalAuthRole=client using authMethod=token, clientVersion=Pulsar-Java-v3.2.0-SNAPSHOT, clientProtocolVersion=21, proxyVersion=3.2.0-SNAPSHOT
    2023-12-06T06:42:14,852 - INFO  - [pulsar-client-io-44-9:ClientCnx@347] - [id: 0xadfa256c, L:/127.0.0.1:48706 ! R:************/127.0.1.1:39725] Disconnected
    2023-12-06T06:42:14,855 - INFO  - [pulsar-proxy-io-42-26:ClientCnx@347] - [id: 0x14c0d475, L:/127.0.0.1:44430 ! R:************/127.0.1.1:34547] Disconnected
    
    
    
    
    
    2023-12-06T06:42:24,191 - INFO  - [pulsar-client-io-137-3:ConnectionPool@270] - [[id: 0xfd5eede1, L:/127.0.0.1:35268 - R:************/127.0.1.1:33501]] Connected to server
    2023-12-06T06:42:24,207 - INFO  - [pulsar-proxy-io-135-5:ConnectionPool@270] - [[id: 0x1c71fa15, L:/127.0.0.1:59474 - R:************/127.0.1.1:36575]] Connected to server
    2023-12-06T06:42:24,212 - INFO  - [pulsar-io-102-1:ServerCnx@731] - [/127.0.0.1:59474] connected role=Proxy and originalAuthRole=client using authMethod=token, clientVersion=Pulsar-Java-v3.2.0-SNAPSHOT, clientProtocolVersion=21, proxyVersion=3.2.0-SNAPSHOT
    2023-12-06T06:42:26,214 - INFO  - [pulsar-proxy-io-135-5:ClientCnx@347] - [id: 0x1c71fa15, L:/127.0.0.1:59474 ! R:************/127.0.1.1:36575] Disconnected
    2023-12-06T06:42:26,253 - INFO  - [pulsar-proxy-io-135-7:ConnectionPool@270] - [[id: 0x2117711d, L:/127.0.0.1:59482 - R:************/127.0.1.1:36575]] Connected to server
    2023-12-06T06:42:26,258 - INFO  - [pulsar-io-102-2:ServerCnx@731] - [/127.0.0.1:59482] connected role=Proxy and originalAuthRole=client using authMethod=token, clientVersion=Pulsar-Java-v3.2.0-SNAPSHOT, clientProtocolVersion=21, proxyVersion=3.2.0-SNAPSHOT
    2023-12-06T06:42:27,205 - INFO  - [pulsar-client-io-137-3:ClientCnx@347] - [id: 0xfd5eede1, L:/127.0.0.1:35268 ! R:************/127.0.1.1:33501] Disconnected
    2023-12-06T06:42:27,206 - INFO  - [pulsar-proxy-io-135-7:ClientCnx@347] - [id: 0x2117711d, L:/127.0.0.1:59482 ! R:************/127.0.1.1:36575] Disconnected
    2023-12-06T06:42:27,217 - INFO  - [pulsar-client-io-137-5:ConnectionPool@270] - [[id: 0xa5e87959, L:/127.0.0.1:35272 - R:************/127.0.1.1:33501]] Connected to server
    2023-12-06T06:42:27,228 - INFO  - [pulsar-proxy-io-135-12:ConnectionPool@270] - [[id: 0xa887c0a9, L:/127.0.0.1:59488 - R:************/127.0.1.1:36575]] Connected to server
    2023-12-06T06:42:27,232 - INFO  - [pulsar-io-102-3:ServerCnx@731] - [/127.0.0.1:59488] connected role=Proxy and originalAuthRole=client using authMethod=token, clientVersion=Pulsar-Java-v3.2.0-SNAPSHOT, clientProtocolVersion=21, proxyVersion=3.2.0-SNAPSHOT
    2023-12-06T06:42:29,235 - INFO  - [pulsar-proxy-io-135-12:ClientCnx@347] - [id: 0xa887c0a9, L:/127.0.0.1:59488 ! R:************/127.0.1.1:36575] Disconnected
    2023-12-06T06:42:29,264 - INFO  - [pulsar-proxy-io-135-14:ConnectionPool@270] - [[id: 0x9fe34a7a, L:/127.0.0.1:59502 - R:************/127.0.1.1:36575]] Connected to server
    2023-12-06T06:42:29,268 - INFO  - [pulsar-io-102-4:ServerCnx@731] - [/127.0.0.1:59502] connected role=Proxy and originalAuthRole=client using authMethod=token, clientVersion=Pulsar-Java-v3.2.0-SNAPSHOT, clientProtocolVersion=21, proxyVersion=3.2.0-SNAPSHOT
    2023-12-06T06:42:30,231 - INFO  - [pulsar-proxy-io-135-14:ClientCnx@347] - [id: 0x9fe34a7a, L:/127.0.0.1:59502 ! R:************/127.0.1.1:36575] Disconnected
    2023-12-06T06:42:30,234 - INFO  - [pulsar-client-io-137-5:ClientCnx@347] - [id: 0xa5e87959, L:/127.0.0.1:35272 ! R:************/127.0.1.1:33501] Disconnected
    2023-12-06T06:42:30,337 - INFO  - [pulsar-client-io-137-7:ConnectionPool@270] - [[id: 0xb189711c, L:/127.0.0.1:35280 - R:************/127.0.1.1:33501]] Connected to server
    2023-12-06T06:42:30,348 - INFO  - [pulsar-proxy-io-135-19:ConnectionPool@270] - [[id: 0xb850dc3e, L:/127.0.0.1:59506 - R:************/127.0.1.1:36575]] Connected to server
    2023-12-06T06:42:30,351 - INFO  - [pulsar-io-102-1:ServerCnx@731] - [/127.0.0.1:59506] connected role=Proxy and originalAuthRole=client using authMethod=token, clientVersion=Pulsar-Java-v3.2.0-SNAPSHOT, clientProtocolVersion=21, proxyVersion=3.2.0-SNAPSHOT
    2023-12-06T06:42:32,353 - INFO  - [pulsar-proxy-io-135-19:ClientCnx@347] - [id: 0xb850dc3e, L:/127.0.0.1:59506 ! R:************/127.0.1.1:36575] Disconnected
    2023-12-06T06:42:32,387 - INFO  - [pulsar-proxy-io-135-21:ConnectionPool@270] - [[id: 0x896a6dfb, L:/127.0.0.1:57736 - R:************/127.0.1.1:36575]] Connected to server
    2023-12-06T06:42:32,391 - INFO  - [pulsar-io-102-2:ServerCnx@731] - [/127.0.0.1:57736] connected role=Proxy and originalAuthRole=client using authMethod=token, clientVersion=Pulsar-Java-v3.2.0-SNAPSHOT, clientProtocolVersion=21, proxyVersion=3.2.0-SNAPSHOT
    2023-12-06T06:42:33,348 - INFO  - [pulsar-client-io-137-7:ClientCnx@347] - [id: 0xb189711c, L:/127.0.0.1:35280 ! R:************/127.0.1.1:33501] Disconnected
    2023-12-06T06:42:33,350 - INFO  - [pulsar-proxy-io-135-21:ClientCnx@347] - [id: 0x896a6dfb, L:/127.0.0.1:57736 ! R:************/127.0.1.1:36575] Disconnected
    2023-12-06T06:42:33,353 - INFO  - [pulsar-client-io-137-9:ConnectionPool@270] - [[id: 0x8ba37811, L:/127.0.0.1:47940 - R:************/127.0.1.1:33501]] Connected to server
    2023-12-06T06:42:33,369 - INFO  - [pulsar-proxy-io-135-26:ConnectionPool@270] - [[id: 0x4a8abb46, L:/127.0.0.1:57740 - R:************/127.0.1.1:36575]] Connected to server
    2023-12-06T06:42:33,373 - INFO  - [pulsar-io-102-3:ServerCnx@731] - [/127.0.0.1:57740] connected role=Proxy and originalAuthRole=client using authMethod=token, clientVersion=Pulsar-Java-v3.2.0-SNAPSHOT, clientProtocolVersion=21, proxyVersion=3.2.0-SNAPSHOT
    
  12. iihimanshuu commented on Mar 3, 2025

    @iihimanshuu

    can i join this issue? im new to open source

  13. tisonkun commented on Mar 3, 2025

    @tisonkun
    Member

    @frhimanshu You're already in. Just share your findings or proposal to move it forward :D

  14. abhinav5481 commented on Mar 14, 2025

    @abhinav5481

    Hi @michaeljmarshall , is this issue still available for contribution? I'd love to work on it if it's unassigned.

  15. TomLucasakaTGeek commented on Nov 21, 2025

    @TomLucasakaTGeek

    Can we use Kotlin to make it asynchronous @michaeljmarshall or use Javascript/Typescript.

  16. merlimat commented on Oct 24, 2026

    @merlimat
    Contributor

    Thanks @michaeljmarshall, and to everyone who offered to help. This is covered by PIP-478 (https://github.com/apache/pulsar/blob/master/pip/pip-478.md), implemented in #26282 for Pulsar 5.0. The new client authentication SPI is fully asynchronous, so OAuth2 and similar plugins no longer block the Netty event loop, and per the PIP the same implementation backs both the v4 and v5 client APIs in 5.0. Closing as completed. If you find a blocking path left, for example in the proxy, please open a new issue for it.

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

    Stalearea/clientgood first issuehelp wantedtype/enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions