Vertx - 使用 OAuth2 保护路由时缺少 GET 参数

Vertx - missing GET parameters while securing route using OAuth2

我遵循了这个使用 OAuth2 和 GitHub 提供商保护路由的示例:http://vertx.io/docs/vertx-web/java/#_oauth2authhandler_handler 并且它工作正常,除了在请求重定向后缺少 GET 参数。

我的代码:

public class MyVerticle extends AbstractVerticle {
    @Override
    public void start() throws Exception {
        HttpServer server = vertx.createHttpServer();
        Router router = Router.router(vertx);

        OAuth2Auth authProviderGitHub = GithubAuth.create(vertx, "<CLIENT_ID>", "<CLIENT_SECRET>");

        OAuth2AuthHandler oauth2 = OAuth2AuthHandler.create(authProviderGitHub, "http://localhost:8080/callback"); 

        oauth2.setupCallback(router.route());

        router.route("/protected/*").handler(oauth2);

        Handler<RoutingContext> requestHandler = (routingContext) -> {
            String paramValue = routingContext.request().getParam("param");
            routingContext.response().end("PARAM: " + paramValue);
        };

        router.get("/endpoint").handler(requestHandler);
        router.get("/protected/endpoint").handler(requestHandler);

        server.requestHandler(router::accept).listen(8080);
    }
}

我有两个简单的端点:

/endpoint     // public, without protection

/protected/endpoint // protected with OAuth2

当我使用

从浏览器 /endpoint 调用时
 http://localhost:8080/endpoint?param=foo 

它按预期工作并且 return PARAM: foo,而当我使用

调用受保护端点时
http://localhost:8080/protected/endpoint?param=foo

它正确地将我重定向到 GitHub 登录页面,然后 return 查询我的处理程序但没有 GET 参数,因此端点的响应是 PARAM: null.

知道我做错了什么吗?

在 vert.x <= 3.4.2 上,只有路径被用于重定向,3.5 系列已经改进并且可以依赖完整的 uri,因此您的代码将适用于该版本。