Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

gseddon
Copy link
Contributor

@gseddon gseddon commented Jun 17, 2020

This handles an issue when the route_prefix is not found in the request_path.
e.g. when

route_prefix = "/audit_logs"
conn.request_path = "/auth/github"

Then the route key incorrectly becomes //auth/github.
This patch fixes it to ensure that it stays as /auth/github

For context, this situation arose from me setting my endpoint url.path to "/audit_logs", but using an ingress controller to rewrite the "/audit_logs" prefix out of all requests once it's forwarded to the application. This is due to phoenix sockets not using the endpoint path.

@gseddon gseddon requested a review from a team as a code owner June 17, 2020 07:29
@tonnenpinguin
Copy link

It seems like this also fixes an issue I ran into last year (#110)

@Hanspagh

lib/ueberauth.ex Outdated
Comment on lines 249 to 253
route_key =
case route_path do
"/" <> _rest -> {route_path, conn.method}
route_path -> {"/" <> route_path, conn.method}
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind creating a function called normalize_route_path where you return the route_path normalized

Suggested change
route_key =
case route_path do
"/" <> _rest -> {route_path, conn.method}
route_path -> {"/" <> route_path, conn.method}
end
route_key = {normaliz_route_path(route_path), conn.method}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@gseddon gseddon force-pushed the fix-disparate-route_prefix branch from 8fb6fe3 to 77991d2 Compare August 23, 2020 06:26
@yordis yordis merged commit bfa98c2 into ueberauth:master Aug 23, 2020
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

Successfully merging this pull request may close these issues.

3 participants