question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PIP-206: Refresh different authentication data

See original GitHub issue

Motivation

For the Pulsar protocol, the client passes the authentication data to the broker/proxy by sending the CommandConnect command.

In the Pulsar proxy, we support forwarding the authentication data from the user client to the broker, this authentication data is named the original authentication data, we also need to pass the proxy’s authentication data, this authentication data is named the self authentication data.

The client supports passing two types of authentication data to connect to the broker, self authentication data and original authentication data in the CommandConnect command.

self authentication: -> CommandConnect.authData.

original authentication: -> CommandConnect.originalAuthData.

When the client/proxy is connected to the broker, the broker starts a thread to check if the authentication data is expired. When both authentication data exist, the broker only supports refreshing the original authentication data and ignores refreshing the self authentication data. When self authentication data is expired, we must consider how to refresh the self authentication data.

Check logic: https://github.com/apache/pulsar/blob/c7b714603a8a9a8bd401e6939dc811f763d65f72/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java#L749

this.authState is ignored.

Goal

Propose an approach that refreshes the different authentication data.

API Changes

  1. Add the original_auth_data field representing which authentication data needs refreshed.
message CommandAuthResponse {
    optional bool original_auth_data = 4 [default = false];
}
  1. Add the refreshOriginalAuthentication method to the AuthenticationState interface.
public interface AuthenticationState {
     /**
     * If the authentication state supports refreshing and the credentials are expired,
     * the auth provider will call this method to initiate the refresh process.
     * <p>
     * The auth state here will return the broker side data that will be used to send
     * a challenge to the client
     *
     * @return the {@link AuthData} for the broker challenge to client
     * @throws AuthenticationException
     */
    default AuthData refreshOriginalAuthentication() throws AuthenticationException {
        return AuthData.of("PulsarOriginalAuthRefresh".getBytes(StandardCharsets.UTF_8));
    }
}

Implementation

For the broker, we need to add a method on the org.apache.pulsar.broker.service.PulsarChannelInitializer to check the self authentication data is expired.

For the client like the original client, or the proxy client, we need to parse the original_auth_data field from the CommandAuthChallenge command, then respond to the correct authentication data to the broker to refresh the authentication data.

For the proxy handler, we need to do some forwarding operations to refresh authentication data.

Alternatives

No response

Anything else?

This change is fully compatible with different versions of client and broker, if the client fails to authenticate, the broker disconnects.

Reference

Discussion thread: https://lists.apache.org/thread/0wz12m255t9xvzf4rtc69c8dlov12764 Voting thread: https://lists.apache.org/thread/gk6wwrtgs8hfqd3x8dt81kgoswxhnbpf

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
michaeljmarshallcommented, Oct 12, 2022

Thanks @nodece, that makes sense to me. Sorry for my delayed review, I’ll try to review the next draft quicker.

0reactions
nodececommented, Oct 12, 2022

I have discussed this with @codelipenghui, @tuteng, and @mattisonchao offline. We will handle this issue on the proxy module to avoid adding complex logic to the broker. Just keep one authentication data on the broker!

Read more comments on GitHub >

github_iconTop Results From Across the Web

PulsarProxy does not always refresh authentication tokens ...
We use Supplier interface in PulsarClient to provide a valid token. The thing is that if we connect directly to brokers token refreshing...
Read more >
Schedule data refresh to a data source with non-Windows ...
If the data model is built by using Windows Authentication, and then is changed to use SQL Server Authentication or any other authentication...
Read more >
No Authentication Method for Refreshing Data Sourc...
However, the refresh function cannot be scheduled, it shows 'Your data source can't be refreshed because the credentials are invalid.
Read more >
dev - The Mail Archive
PIP-Java Client support to Cumulative Acknowledge messages for multiple partitions ... [DISCUSS][PIP-206] Refresh different authentication data Zixuan Liu ...
Read more >
How to reload authorities on user update with Spring Security
If I am logged in as "x" and I'd like to revoke "y" authorities, how do I get Authentication's object from that specific...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found