widgetti / solara

A Pure Python, React-style Framework for Scaling Your Jupyter and Web Apps
https://solara.dev
MIT License
1.9k stars 141 forks source link

OAuth flow breaking due to wrong base url variable being used #740

Closed cyrfar closed 2 months ago

cyrfar commented 2 months ago

Hi, I was trying to test auth in a Solara app and noticed that somewhere along the way redirect urls get overwritten by a default values rather than use the SOLARA_BASE_URL that I set in my environment. I suspect maybe the redirect_uri being passed here

result = await oauth.oauth1.authorize_redirect(request, str(request.base_url) + "_solara/auth/authorize")

should be using settings.main.base_url (which correctly updates when I set SOLARA_BASE_URL) instead of request.base_url (which is based on default values).

In a more detailed discussion with @maartenbreddels in the Discord channel we suspect this to be a small bug and a fix could potentially resolve the issue.

maartenbreddels commented 2 months ago

Two things are going on here.

  1. If the configuration was ok, this would not have happened. It's mentioned in the docs at https://solara.dev/documentation/getting_started/deploying/self-hosted but it also took me a while to realize this was the problem. Based on this, I created #745
  2. Yes, this is/was/count be considered a bug, but with #745 you should get a warning before this issue shows up.

Lets first see if #745 would have given you the hints to get it working faster.

cyrfar commented 2 months ago

Hi Maarten, I deployed to AWS (without the proper proxy/uvicorn config on purpose) and indeed got the warning in the logs

image

Locally (where there is no proxy server), I do not get the warning, as expected.

maartenbreddels commented 2 months ago

Great, do you think this would have helped you from the start?

cyrfar commented 2 months ago

Yes!