Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rx Version of OAuth2AuthHandler Handler fails to add scopes #2608

Open
pendula95 opened this issue May 10, 2024 · 2 comments
Open

Rx Version of OAuth2AuthHandler Handler fails to add scopes #2608

pendula95 opened this issue May 10, 2024 · 2 comments
Labels
Milestone

Comments

@pendula95
Copy link
Member

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:

/**
* Return a <b>new instance</b> with the internal state copied from the caller but the scopes to be requested during
* a token request are unique to the instance. When scopes are applied to the handler, the default scopes from the
* route metadata will be ignored.
*
* @param scope scope.
* @return new instance of this interface.
*/
@Fluent
OAuth2AuthHandler withScope(String scope);

* Return a <b>new instance</b> with the internal state copied from the caller but the scopes to be requested during
* a token request are unique to the instance. When scopes are applied to the handler, the default scopes from the
* route metadata will be ignored.
*
* @param scopes scopes.
* @return new instance of this interface.
*/
@Fluent
OAuth2AuthHandler withScopes(List<String> scopes);

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 pendula95 added the bug label May 10, 2024
@pendula95
Copy link
Member Author

Some insight why this behavior was introduced #2219 (comment)

@tsegismont
Copy link
Contributor

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 tsegismont added this to the 4.5.8 milestone May 21, 2024
@vietj vietj modified the milestones: 4.5.8, 4.5.9 May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants