vertx-auth
vertx-auth copied to clipboard
Infinite Redirects when "Authorization" header is not passed explicitly
Version
3.8.5
Context
The OAuth2AuthHandler enters a redirect loop if the Bearer is not present and Sessions are enabled.
What happens:
- User requests a protected route.
- User is redirected to keycloak.
- User is now (or was) authenticated, redirect user to callback route.
- Redirect user to "state" route, usually step 1 route
- Bearer not found, redirect user back to keycloak
- Repeat 3 to 5 infinitely
The "redirect if Bearer not found" can be found here:
https://github.com/vert-x3/vertx-web/blob/8ed1511766697c9ee9e7e5acaad9041f2ca4c384/vertx-web/src/main/java/io/vertx/ext/web/handler/impl/OAuth2AuthHandlerImpl.java#L81-L119
Edit: Also, "setupCallback" redirects user back to the route specified by the "state" parameter
Do you have a reproducer?
https://github.com/LouizFC/vertx-infinite-loop-reproducer
Steps to reproduce
- Import the realm-export.json into a new keycloak realm.
- Regenerate the "vertx" client secret at the Client > vertx > Credentials tab
- Create a test user
- Export the OIDC JSON into the app MainVerticle class, removing trailing slashes from the auth url
- Run the app and open localhost:8080/user at the browser
- Login with the test user
- Infinite loop
Thanks for the report, I'll investigate it.
I believe this issue is solved. Please re-open if not.