Skip to content

Commit

Permalink
Merge pull request #4461 from geoand/defensive-send-challenge
Browse files Browse the repository at this point in the history
Be defensive with closeTask in HttpAuthenticator#sendChallenge
  • Loading branch information
geoand authored Oct 9, 2019
2 parents dd59793 + ae338e0 commit 180a1f7
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ public CompletionStage<SecurityIdentity> attemptAuthentication(RoutingContext ro
* @return
*/
public CompletionStage<Void> sendChallenge(RoutingContext routingContext, Runnable closeTask) {
if (closeTask == null) {
closeTask = NoopCloseTask.INSTANCE;
}
if (mechanism == null) {
routingContext.response().setStatusCode(HttpResponseStatus.FORBIDDEN.code());
closeTask.run();
Expand All @@ -83,4 +86,14 @@ public CompletionStage<Void> sendChallenge(RoutingContext routingContext, Runnab
return mechanism.sendChallenge(routingContext).thenRun(closeTask);
}

static class NoopCloseTask implements Runnable {

static final NoopCloseTask INSTANCE = new NoopCloseTask();

@Override
public void run() {

}
}

}

0 comments on commit 180a1f7

Please sign in to comment.