Skip to content

Commit

Permalink
JVMCBC-535: Make sure PLAIN is bailed out early.
Browse files Browse the repository at this point in the history
Motivation
----------
The previous changeset left out one possible complication, namely
that the PLAIN auth method finished earlier and so the evaluate
challenge step failed.

Modifications
-------------
This changeset makes sure that before the challenge is evaluated,
it is checked if the exchange already finished. Also in the process
it was found that the response might already come back with an
auth error as part of the status, so in this case we can short-circuit
and fail the process right away.

Result
------
Proper handling of PLAIN SASL auth as well as short-circuiting sasl
auth response status codes.

Change-Id: I37e718d7e2a252c91ba7e1747378a9da993ddbf3
Reviewed-on: http://review.couchbase.org/94201
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Senol Ozer <senol.ozer@amadeus.com>
Reviewed-by: David Nault <david.nault@couchbase.com>
Reviewed-by: Graham Pople <grahampople@gmail.com>
  • Loading branch information
daschl committed May 22, 2018
1 parent 29d8b33 commit 8bdfe36
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,15 @@ public void operationComplete(Future<Void> future) throws Exception {
private void handleAuthResponse(ChannelHandlerContext ctx, FullBinaryMemcacheResponse msg) throws Exception {
byte[] response = new byte[msg.content().readableBytes()];
msg.content().readBytes(response);

// Under PLAIN it might be already complete, so bail out early if so.
// Also, make sure that auth failure response codes are covered early
// and bailed out before evaluating the challenge.
if (saslClient.isComplete() || msg.getStatus() == SASL_AUTH_FAILURE) {
checkIsAuthed(msg);
return;
}

byte[] evaluatedBytes = saslClient.evaluateChallenge(response);

// This condition is needed for evaluate SASL Step Response.
Expand Down

0 comments on commit 8bdfe36

Please sign in to comment.