vertx-web icon indicating copy to clipboard operation
vertx-web copied to clipboard

Rx Version of OAuth2AuthHandler Handler fails to add scopes

Open pendula95 opened this issue 1 year ago • 2 comments

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 avatar May 10 '24 14:05 pendula95

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

pendula95 avatar May 15 '24 09:05 pendula95

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 ?

tsegismont avatar May 21 '24 08:05 tsegismont