Skip to content
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

ISPN-9841 Non-blocking Hot Rod authentication #6801

Merged

Conversation

tristantarrant
Copy link
Member

@tristantarrant
Copy link
Member Author

3 related failures

@tristantarrant tristantarrant force-pushed the ISPN-9841/nonblocking_auth branch 2 times, most recently from 3717f60 to 0abfdfd Compare March 27, 2019 08:23
@tristantarrant
Copy link
Member Author

Fixed the failures by reordering how we handle "complete" authentication. Before sending the final server response, we obtain the subject from the auth backend.

@rvansa
Copy link
Member

rvansa commented Mar 28, 2019

There are couple of places where the auth process throws an exception. In the original code this was handled in the server (writing the error response) but I am afraid here it just gets logged and the client does not get any response until it times out. Could you make sure to write some response on any code path?

@tristantarrant
Copy link
Member Author

@rvansa are you sure ? I'm just wrapping the exceptions into a SecurityException which will then be handled by HotRodDecoder.decode()'s catch

saslServer = Subject.doAs(authenticationConfig.serverSubject(), (PrivilegedExceptionAction<SaslServer>) () ->
ssf.createSaslServer(mech, "hotrod", authenticationConfig.serverName(),
authenticationConfig.mechProperties(), callbackHandler));
} else {
} catch (PrivilegedActionException e) {
throw new SecurityException(writeException(header, e.getCause()));
Copy link
Member

Choose a reason for hiding this comment

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

Why are you throwing that here? Can't you just log the PAE, writeException and return?

saslServer = ssf.createSaslServer(mech, "hotrod", authenticationConfig.serverName(),
authenticationConfig.mechProperties(), callbackHandler);
} catch (SaslException e) {
throw new SecurityException(writeException(header, e));
Copy link
Member

@rvansa rvansa Mar 28, 2019

Choose a reason for hiding this comment

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

In general I find calling a method with side-effect in exception ctor a bit cryptic (couldn't spot where it is written for a while), though YMMV.

@tristantarrant
Copy link
Member Author

Yeah, that was really silly of me. I've changed that @rvansa

}
writeResponse(header, header.encoder().authResponse(header, server, channel.alloc(), serverChallenge));

if (saslServer.isComplete()) {
Copy link
Member

Choose a reason for hiding this comment

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

Isn't here a race between responding with the authResponse and adding the QOP handler below?

Copy link
Member

Choose a reason for hiding this comment

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

@rvansa @tristantarrant isn't this still valid?

throw log.externalMechNotAllowedWithoutSSLClientCert();
} catch (SSLPeerUnverifiedException e) {
throw log.externalMechNotAllowedWithoutSSLClientCert();
executor.execute(() -> authInternal(header, mech, response));
Copy link
Member

Choose a reason for hiding this comment

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

While you have handled all the declared exceptions, I would still feel a bit more warm&fuzzy if any unexpected exceptions (NPEs...) would be handled with a response...

@tristantarrant
Copy link
Member Author

@rvansa I believe I've addressed everything

Copy link
Member

@rvansa rvansa left a comment

Choose a reason for hiding this comment

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

LGTM, let's hope the testsuite agrees.

@tristantarrant
Copy link
Member Author

Kicked-off a new CI build as the previous one crashed in core (unrelated to this PR)

@tristantarrant
Copy link
Member Author

A green build !
:bowtie:

@karesti karesti merged commit 4b05f8b into infinispan:master Apr 3, 2019
@tristantarrant tristantarrant deleted the ISPN-9841/nonblocking_auth branch January 21, 2020 07:32
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.

4 participants