Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The exact difference in behaviour is that all the existing drivers will always send an ApiVersions request as the first request when opening a new connection.
However the sarama and kafkajs driver will sometimes skip the ApiVersions request when opening a connection. This is valid use of the protocol and its a bug in shotover that we are not handling this case properly.
Skipping the ApiVersions request resulted in shotover attempting to open the first outgoing connection of an incoming connection using a delegation token, this failed since we havent yet gathered the username required for creating a delegation token.
The fix here is to only use token auth when OriginalScramState::AuthSuccess.
If we are in any other state we should perform no handshake.
Along with the fix, this PR also refactors AuthorizeScramOverMtls to make it impossible to retrieve the username until a successful auth has completed.
While this is impossible to reach due to the above fix, I believe the security in depth is valuable here.
Additionally this refactor enables us to prefetch tokens which should be a reasonable perf gain on production systems with many nodes.
The first commit introduces a failing test case
cluster_sasl_scram_over_mtls_nodejs
which is fixed by the 2nd commit.The kafkajs tests are added as a simple smoke test for now.
However, in the future we should be able to extend this into: