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

Add access to Router in AuthHandlerFactory #42

Open
Mateusz512 opened this issue Jan 29, 2020 · 2 comments
Open

Add access to Router in AuthHandlerFactory #42

Mateusz512 opened this issue Jan 29, 2020 · 2 comments

Comments

@Mateusz512
Copy link

Mateusz512 commented Jan 29, 2020

Is your feature request related to a problem? Please describe.
When attempting to implement OAuth2 based security, with OOTB Vert.x functionalities, I've encountered a need to register custom routing when creating the handler.

Describe the solution you'd like
AuthHandlerFactory should have the possibility to register some custom routing, required for example for an OAuth2 callback.

Describe alternatives you've considered
It is possible to implement it as two different OpenAPI3 based endpoints, but it breaks the isolation between security logic and routing logic (business logic).

@malaskowski
Copy link
Member

How about using callbacks option as a part of the defined OpenAPI3 operation?
You can then define a custom callback for OAuth2.
There is also quite extensive explanation with examples available in the Swagger spec: https://swagger.io/docs/specification/callbacks/

@Mateusz512
Copy link
Author

How about using callbacks option as a part of the defined OpenAPI3 operation?
You can then define a custom callback for OAuth2.
There is also quite extensive explanation with examples available in the Swagger spec: https://swagger.io/docs/specification/callbacks/

Looks nice, but the catch is that with current implementation of OAuth2 flow in Vert.x I need to specifically call OAuth2AuthHandlerImpl#setupCallback which takes Route as a param. Under the hood it is explicitly registering a handler for retrieving the authentication code and exchanging it for access token:

    ...
    route.handler(ctx -> {
      // Handle the callback of the flow
      ...
    });

    // the redirect handler has been setup so we can process this
    // handler has full oauth2
    bearerOnly = false;
    callback = route;

    return this;
  }

The bearerOnly = false is crucial as well, it prevents the inital request from being revoked right away (yep, this field is private 😒 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants