-
Notifications
You must be signed in to change notification settings - Fork 462
[server] Add retriable authentication exception. #845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| if (!authenticator.isCompleted()) { | ||
| byte[] token = authenticateRequest.getToken(); | ||
| byte[] challenge = authenticator.evaluateResponse(token); | ||
| if (!authenticator.isCompleted() && challenge != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the removal of !authenticator.isCompleted() necessary? I though the authenticator.evaluateResponse may change status of authenticator into complete and don't need to send challenge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some authentication protocol, the server will be complete before the client becomes complete.
Take SCRAM-SHA-256 of kafka for example,
- sasl server recieves RECEIVE_CLIENT_FINAL_MESSAGE, and then mark authenticator server status as COMPLETE, then still send serverFinalMessage
// org.apache.kafka.common.security.scram.internals.ScramSaslServer#evaluateResponse
case RECEIVE_CLIENT_FINAL_MESSAGE:
try {
ClientFinalMessage clientFinalMessage = new ClientFinalMessage(response);
verifyClientProof(clientFinalMessage);
byte[] serverKey = scramCredential.serverKey();
byte[] serverSignature = formatter.serverSignature(serverKey, clientFirstMessage, serverFirstMessage, clientFinalMessage);
ServerFinalMessage serverFinalMessage = new ServerFinalMessage(null, serverSignature);
clearCredentials();
setState(State.COMPLETE);
return serverFinalMessage.toBytes();
} catch (InvalidKeyException e) {
throw new SaslException("Authentication failed: Invalid client final message", e);
}- Then sasl client recieve this RECEIVE_SERVER_FINAL_MESSAGE, then will set status and State.COMPLETE and then return null(no longer send anymore)
org.apache.kafka.common.security.scram.internals.ScramSaslClient#evaluateChallenge
case RECEIVE_SERVER_FINAL_MESSAGE:
ServerFinalMessage serverFinalMessage = new ServerFinalMessage(challenge);
if (serverFinalMessage.error() != null)
throw new SaslException("Sasl authentication using " + mechanism + " failed with error: " + serverFinalMessage.error());
handleServerFinalMessage(serverFinalMessage.serverSignature());
setState(State.COMPLETE);
return null;I add same logic in com.alibaba.fluss.rpc.netty.authenticate.MutualAuthenticationPlugin.
fluss-rpc/src/main/java/com/alibaba/fluss/rpc/netty/client/ServerConnection.java
Show resolved
Hide resolved
fluss-rpc/src/main/java/com/alibaba/fluss/rpc/netty/client/NettyAuthenticationHandler.java
Outdated
Show resolved
Hide resolved
fluss-rpc/src/main/java/com/alibaba/fluss/rpc/netty/client/NettyAuthenticationHandler.java
Outdated
Show resolved
Hide resolved
fluss-rpc/src/main/java/com/alibaba/fluss/rpc/netty/client/NettyAuthenticationHandler.java
Outdated
Show resolved
Hide resolved
fluss-rpc/src/main/java/com/alibaba/fluss/rpc/netty/client/NettyAuthenticationHandler.java
Outdated
Show resolved
Hide resolved
fluss-rpc/src/main/java/com/alibaba/fluss/rpc/netty/client/NettyAuthenticationHandler.java
Outdated
Show resolved
Hide resolved
d2e00e7 to
4d5ec5b
Compare
|
Rebase this pr with three modification:
|
fluss-common/src/main/java/com/alibaba/fluss/security/auth/ServerAuthenticator.java
Outdated
Show resolved
Hide resolved
fluss-common/src/main/java/com/alibaba/fluss/utils/ExponentialBackoff.java
Show resolved
Hide resolved
fluss-rpc/src/main/java/com/alibaba/fluss/rpc/netty/client/ServerConnection.java
Outdated
Show resolved
Hide resolved
|
Maybe we can verify this pr in our env before merge that to avoid go back and forth. Maybe in this afternoon or tomorrow to verify this pr. |
ok, I will apply the modification of this pr to env test. |
|
@loserwang1024 please ping me when you have verified in internal env. |
|
It is passed in our internal env. |
Purpose
Linked issue: close #844
Brief change log
Tests
com.alibaba.fluss.rpc.netty.authenticate.AuthenticationTest#testRetirableAuthenticateException
API and Format
Documentation