Skip to content

Fixed authentication flow via Pulsar Proxy - #1707

Merged
jai1 merged 9 commits into
apache:masterfrom
jai1:proxyAuthFix
May 3, 2018
Merged

Fixed authentication flow via Pulsar Proxy#1707
jai1 merged 9 commits into
apache:masterfrom
jai1:proxyAuthFix

Conversation

@jai1

@jai1 jai1 commented May 2, 2018

Copy link
Copy Markdown
Contributor

Currently, the broker/proxy authenticates the proxy/client when the connection is established (via Server.handleConnect or ProxyConnection.handleConnect) after that we cache the authRole we extract. The connection persists long after the authData expires since we use the cached authRole then onwards.

In #1169 in order to preserve the Connection pool in ProxyLookupHandler, I changed the proxy code to cache the client authData and forward it to authenticate during lookups and getPartitionMetaData what I failed to see was that if the client authData expires broker will reject the lookups, since we are sending old Client authData.

The fix for this is that for lookups instead of maintaining a single connection pool in proxy we maintain one connection pool per client connection and authenticate both the client and the proxy only when a new connection is created.

@jai1 jai1 self-assigned this May 2, 2018
@jai1
jai1 requested review from maskit, merlimat, rdhabalia and sijie May 2, 2018 06:15
@jai1 jai1 added this to the 2.0.0-incubating milestone May 2, 2018
@jai1 jai1 added the type/bug The PR fixed a bug or issue reported a bug label May 2, 2018
@merlimat

merlimat commented May 2, 2018

Copy link
Copy Markdown
Contributor

@jai1 This doesn't seem to me a super-critical error to stop the current RC. I think we can bump to 2.0.1 where we'll get all fixes (and we should do soon).

@jai1

jai1 commented May 2, 2018

Copy link
Copy Markdown
Contributor Author

@merlimat - ok changed the milestone to 2.0.1, can you review this PR

@rdhabalia rdhabalia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.. few comments.

@Override
protected ByteBuf newConnectCommand() throws PulsarClientException {
if (log.isDebugEnabled()) {
log.info(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log.debug(..)

"New Connection opened via ProxyClientCnx with params clientAuthRole = {}, clientAuthData = {}, clientAuthMethod = {}",
clientAuthRole, clientAuthData, clientAuthMethod);
}
String authData = "";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we initialize with null?

try {
client.close();
} catch (PulsarClientException e) {
LOG.error("Unable to clode pulsar client - {}", client);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type close and add e.getMessage() in log

this.clientAuthData = authData;
this.clientAuthMethod = authMethod;
}
createClient(clientConf, this.clientAuthData, this.clientAuthMethod);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as name suggests. can we create and return client in createClient(): this.client = createClient(..)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also we don't want to share proxy-to-broker connection when service.getConfiguration().forwardAuthorizationCredentials() is enabled. else, we can always share proxy-to-broker connection for lookup.
so, should we create a new client only in case of service.getConfiguration().forwardAuthorizationCredentials()=true else we can always share it.?

proxyService.close();
}

private void createAdminClient() throws PulsarClientException {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createAdminClient() name seems misleading as we are not closing admin and we may think it's leaking. so, probably we can rename it as updateAdmin()?

}
}

private int webServicePort;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we move it to top?


private final EventLoopGroup acceptorGroup;
private final EventLoopGroup workerGroup;
final EventLoopGroup workerGroup;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we keep it private?

@rdhabalia rdhabalia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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

Labels

type/bug The PR fixed a bug or issue reported a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants