-
Notifications
You must be signed in to change notification settings - Fork 131
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
Oauth2, FastAPI, and Solara #157
Comments
Hi, If I understand correctly, you try to follow https://solara.dev/docs/enterprise/oauth but with your app mounted under a different path as the root, right? And you are using our Auth0 setup, i.e. you didn't set it up yourself? The problem lies, that in our default configuration, we have the URL's configured like this: If you have a different root path, auth0 will not allow that. If you create your own auth0 account and follow all the steps in the documentation and prefix the Let us know if you run into issues!
Thank you :) |
Hey, sorry for the delayed response. So, it seems like there are two issues. The first is as you mentioned. I need to route things differently in Auth0. The second is that the auth path is hardcoded.
I guess I can just manually create my own utility function. I'll test this out. Is there a way that the mount path for Solara can be detected and injected into the utility functions? |
Good catch, this is fixed in the linked commit and released as 1.17.4 |
Last comment. I'm not sure if this is a bug or not. When mounting Solara to FastAPI using auth, I get this error: AssertionError: SessionMiddleware must be installed to access request.session I dug around in the source code, and it looks like the Starlette integrations inject the I was able to get it working properly by directly adding in the from fastapi import FastAPI
import solara.server.fastapi
from starlette.middleware.sessions import SessionMiddleware
app = FastAPI()
app.add_middleware(SessionMiddleware, secret_key="random-string")
app.mount("/", app=solara.server.fastapi.app) If you comment out the |
Oh, and just to confirm, I upgraded and things worked. Thanks for the fix on the first issue. |
I think this is a bug, we should add the middleware to fastapi as well. |
I did my best to search the docs, but I wasn't able to find an answer.
I want to implement Solara into a FastAPI application.
I also want to use Auth0 in the Solara application.
I admittedly not super knowledgeable about auth.
I tried following the docs on Auth0, and I cannot seem to get it to work. I suspect it is because the
get_login_url
is effectively hard coding the login URL. This means that if I mount Solara to a different path, then the auth endpoint seems like it might not work.Is this correct? Is there a better workaround for this?
Also, love the project. I have built APIs in the past, and I have always thought a good Python frontend framework was lacking. I was considering using Anvil, but I hate using anything that isn't open source and free to use. Keep up the good work.
The text was updated successfully, but these errors were encountered: