vert-x3 / vertx-web

HTTP web applications for Vert.x
Apache License 2.0
1.11k stars 534 forks source link

Rx Version of OAuth2AuthHandler Handler fails to add scopes #2608

Open pendula95 opened 5 months ago

pendula95 commented 5 months ago

Version

4.5.7

Context

Rx Version of OAuth2AuthHandler Handler fails to send correct scopes. This happens because during initialization of the OAuth2AuthHandler object new instance is ignored because of how rx code is generated.

Do you have a reproducer?

Yes please find the reproducer attached https://gist.github.com/pendula95/0460494f9f6bacaf6ec8e5c63473fe70

This is because of following lines: https://github.com/vert-x3/vertx-web/blob/03f75d5157615785a20a564cd133d5eb5ce90075/vertx-web/src/main/java/io/vertx/ext/web/handler/OAuth2AuthHandler.java#L78-L87

https://github.com/vert-x3/vertx-web/blob/03f75d5157615785a20a564cd133d5eb5ce90075/vertx-web/src/main/java/io/vertx/ext/web/handler/OAuth2AuthHandler.java#L90-L98

Generated RX Class looks like this:

  public io.vertx.rxjava3.ext.web.handler.OAuth2AuthHandler withScopes(java.util.List<java.lang.String> scopes) { 
    delegate.withScopes(scopes);
    return this;
  }
  public io.vertx.rxjava3.ext.web.handler.OAuth2AuthHandler withScope(java.lang.String scope) { 
    delegate.withScope(scope);
    return this;
  }

This results in delegate never updating with new config.

pendula95 commented 5 months ago

Some insight why this behavior was introduced https://github.com/vert-x3/vertx-web/issues/2219#issuecomment-1164289681

tsegismont commented 5 months ago

As a workaround, you can create a new instance of the Rxified handler using the object returned by getDelegate().withScope(scope)

In Vert.x 5, the problem is fixed by #2413

In Vert.x 4, I believe we should remove the @Fluent annotations from the relevant methods.

Fine with you @vietj ?