Skip to content

KAFKA-3652: Return error response for unsupported version of ApiVersionsRequest#1310

Closed
rajinisivaram wants to merge 2 commits into
apache:trunkfrom
rajinisivaram:KAFKA-3652
Closed

KAFKA-3652: Return error response for unsupported version of ApiVersionsRequest#1310
rajinisivaram wants to merge 2 commits into
apache:trunkfrom
rajinisivaram:KAFKA-3652

Conversation

@rajinisivaram
Copy link
Copy Markdown
Contributor

@rajinisivaram rajinisivaram commented May 3, 2016

Handle unsupported version of ApiVersionsRequest during SASL auth as well as normal operation by returning an error response.

@rajinisivaram rajinisivaram changed the title KAFKA-3652: Allow atmost one ApiVersionsRequest before SASL handshake KAFKA-3652: Return error response for unsupported version of ApiVersionsRequest May 4, 2016
try {
// For unsupported version of ApiVersionsRequest, create a dummy request to enable an error response to be returned later
if (header.apiKey == ApiKeys.API_VERSIONS.id && !Protocol.apiVersionSupported(header.apiKey, header.apiVersion))
new ApiVersionsRequest
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It may be better to just respond with the error from here instead of creating this dummy request. But let's see what @junrao says.

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.

Yes, the logic here is a bit awkward, but probably the simplest. Sending a response directly from SocketServer seems to require more work.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ijuma @junrao Thank you both for the reviews. I took a look at changing this, but left it as is to keep the code change small.

@ijuma
Copy link
Copy Markdown
Member

ijuma commented May 4, 2016

Thanks for the PR @rajinisivaram, I had a quick look and it seems fine apart from one comment. Let's wait for @junrao to take a look as well.


public enum SaslState {
HANDSHAKE_REQUEST, AUTHENTICATE, COMPLETE, FAILED
GSSAPI_OR_HANDSHAKE_REQUEST, HANDSHAKE_REQUEST, AUTHENTICATE, COMPLETE, FAILED
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.

Hmm, I am not quite sure what the new state GSSAPI_OR_HANDSHAKE_REQUEST is for. It's making the same call as the HANDSHAKE_REQUEST and there is no code to change saslState to GSSAPI_OR_HANDSHAKE_REQUEST.

Copy link
Copy Markdown
Contributor Author

@rajinisivaram rajinisivaram May 4, 2016

Choose a reason for hiding this comment

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

@junrao Oops, sorry, missed out the change of initiate state. In HANDSHAKE_REQUEST state, any invalid request is treated as a GSSAPI token. This made sense when only a SaslHandshakeRequest was expected prior to SASL tokens. Since SaslHandshakeRequest can now be preceded by any number of ApiVersionsRequests, I think it makes sense to revert to 0.9.0.x GSSAPI authentication only for the first token. GSSAPI_OR_HANDSHAKE_REQUEST is the initiate state which checks that. Have updated the PR.

case HANDSHAKE_REQUEST:
handleKafkaRequest(clientToken);
break;
case GSSAPI_OR_HANDSHAKE_REQUEST:
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.

Could we move this case to the first one after switch since it's the initial state?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@junrao We are relying on fall-through for the second case, so it's not straightforward to make that change.

@junrao
Copy link
Copy Markdown
Contributor

junrao commented May 5, 2016

@rajinisivaram : Thanks for the latest patch. LGTM. Just left a couple of minor comments.

@junrao
Copy link
Copy Markdown
Contributor

junrao commented May 5, 2016

@ijuma : Yes, your comments make sense. The patch LGTM then.

asfgit pushed a commit that referenced this pull request May 5, 2016
…onsRequest

Handle unsupported version of ApiVersionsRequest during SASL auth as well as normal operation by returning an error response.

Author: Rajini Sivaram <rajinisivaram@googlemail.com>

Reviewers: Ismael Juma <ismael@juma.me.uk>, Jun Rao <junrao@gmail.com>

Closes #1310 from rajinisivaram/KAFKA-3652

(cherry picked from commit 64451af)
Signed-off-by: Jun Rao <junrao@gmail.com>
@asfgit asfgit closed this in 64451af May 5, 2016
gfodor pushed a commit to AltspaceVR/kafka that referenced this pull request Jun 3, 2016
…onsRequest

Handle unsupported version of ApiVersionsRequest during SASL auth as well as normal operation by returning an error response.

Author: Rajini Sivaram <rajinisivaram@googlemail.com>

Reviewers: Ismael Juma <ismael@juma.me.uk>, Jun Rao <junrao@gmail.com>

Closes apache#1310 from rajinisivaram/KAFKA-3652
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants