Skip to content

Commit

Permalink
fix: mitigate problem with ChainAuthHandler
Browse files Browse the repository at this point in the history
A problem with the ChainAuthHandler was introduced in vert.x version
4.5.6. To mitigate the issue, we do not use the vert.x
ChainAuthHandler when only one AuthenticationHandler is used. The
problem still exists when more than one AuthenticationHandler is used.

vert-x3/vertx-web#2611
  • Loading branch information
halber committed Jun 6, 2024
1 parent 3685bd5 commit 5f93cd7
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/main/java/io/neonbee/internal/handler/ChainAuthHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ static ChainAuthHandler create(Vertx vertx, List<AuthHandlerConfig> authChainCon
return NOOP_AUTHENTICATION_HANDLER;
}

List<AuthenticationHandler> authHandlers = authChainConfig.stream()
.map(config -> config.createAuthHandler(vertx)).toList();

if (authHandlers.size() == 1) {
AuthenticationHandler authenticationHandler = authHandlers.get(0);
return authenticationHandler::handle;
}

io.vertx.ext.web.handler.ChainAuthHandler chainAuthHandler = io.vertx.ext.web.handler.ChainAuthHandler.any();
List<AuthenticationHandler> authHandlers =
authChainConfig.stream().map(config -> config.createAuthHandler(vertx)).toList();
authHandlers.forEach(chainAuthHandler::add);

return new ChainAuthHandler() {
@Override
public void handle(RoutingContext event) {
chainAuthHandler.handle(event);
}
};
return chainAuthHandler::handle;
}
}

0 comments on commit 5f93cd7

Please sign in to comment.