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

Setting the callback url manually when autodetection is incorrect. #83

Closed
wmealing opened this issue Feb 9, 2023 · 5 comments
Closed

Comments

@wmealing
Copy link

wmealing commented Feb 9, 2023

Gday,

I have found a case where the auto generation of the callback url fails. If you're running phoenix on port 80 behind a proxy (like on fly.io) the auto generated callback url defaults to http, even though fly.io automatically proxies the node to https.

When this is the case, the default callback_uri ends up being incorrect and not matching the expected protocol/name that google expects.

I did not find a good way around this, other than hacking the code to allow an environment / config variable to set the protocol and server. Is there a better way that you recommend ?

If you're interested I can perhaps do a first draft of a patch and submit, however I thought i'd talk about the problem before going that route.

Thanks for this project.

@wmealing wmealing changed the title Setting the callback url manually. Setting the callback url manually when autodetection is incorrect. Feb 9, 2023
@nelsonic
Copy link
Member

nelsonic commented Feb 9, 2023

Hi @wmealing, thanks for opening this issue to give your feedback.
Keen to get a bit more detail on this.

The demo version of this was deployed to Fly.io: https://elixir-google-auth-demo.fly.dev
PR: dwyl/elixir-auth-google-demo#16

If you'd like to help us understand the challenge you're facing,
please fork the demo (once the PR is merged) and show us how you arrive at the incorrect outcome. 🙏
Thanks again.

@wmealing
Copy link
Author

I'll work on trying to figure out the difference, I'm not super competent at web programming. This will take a little while. I checked the other PR's and thats a lot of work to help debug this issue. Will respond here when I figure out what i've done wrong.

@nelsonic
Copy link
Member

@wmealing we're all learning. doubt you've done anything "wrong". 💭
there are always various routes to the same goal in software engineering. 😉
if anything our documentation is not good enough for a seamless developer experience. 🤦‍♂️
and for highlighting that, we are very grateful to you. 🙏

@wmealing
Copy link
Author

I believe that I had the configuration of "url" incorrect in my config/prod.exs

config :myapp, MyApp.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json",
  ....
  url: [scheme: "https", host: "mealing.dev", port: 443],
  ....

When I changed this, it now generates the correct redirect_uri.

Thank you for taking the time to steer me in the right direction.

@nelsonic
Copy link
Member

@wmealing thanks for confirming. Glad you figured it out. 👌

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

No branches or pull requests

2 participants