-
Notifications
You must be signed in to change notification settings - Fork 71
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
[BUG/Question] Fixing TypeError during WebSocket Authentication Migration from FastAPI 0.96 to 0.97 #155
Comments
Hi, I haven't looked at websockets much, but I'll try to check this out tomorrow. Does it work on newer versions such as 0.103.2? |
Big thanks. I tried to migrate to 0.102.0, and my first attempt resulted in the same error |
I’m sorry, I didn’t get to this today, but as far as I can see, it’s been added a way to natively use dependencies and websockets: https://github.com/tiangolo/fastapi/releases/tag/0.97.0 I suspect you could validate tokens with a |
Thank you for the update. Unfortunately, I tried out the solution you suggested, but I encountered the same error as before |
I was looking at the PR and corresponding description, and the issue might be deeper than I expected - fastapi/fastapi#4534 It seems that Auth for Websocket might have never worked and the 0.97 release helped to realize it 😕. Perhaps adding Security(azure_auth) for Websocket router at all was not the right choice initially |
Ouf, I see. That's not great, good someone caught it. There's some design questions that needs to be made though:
|
any news on that issue? I am facing the same issue right now. |
No, not really. I haven't looked much into it, and probably won't find the time for a while. |
#200 will fix this. |
Describe the bug
I am trying to migrate from FastAPI 0.96 to 0.97 and have
azure_scheme
as a dependency to protect my WebSocket connection. I think some changes were introduced in FastAPI related to WebSocket dependency and now I am having conflicts between connect from React and API. I'm more of a person who supports change, so if the initial setup was incorrect, then I will be glad to receive advice on a more correct setup or any workaroundTo Reproduce
Steps to reproduce the behavior:
Stack trace
Your configuration
Config from pyproject.toml:
[tool.poetry.dependencies]
python = "3.11.3"
fastapi = "0.97.0"
httpx = "0.23.3"
psycopg2-binary = "2.9.5"
asyncpg = "0.27.0"
sqlalchemy = "2.0.6"
pydantic = {extras = ["dotenv"], version = "1.10.6"}
asyncpg-listen = "^0.0.6"
fastapi-azure-auth = "^4.0.0"
greenlet = "^2.0.2"
opentelemetry-instrumentation-fastapi = "^0.40b0"
opentelemetry-instrumentation-logging = "^0.40b0"
opentelemetry-exporter-otlp = "^1.19.0"
opentelemetry-api = "^1.19.0"
opentelemetry-sdk = "^1.19.0"
prometheus-fastapi-instrumentator = "^6.1.0"
uvicorn = {extras = ["standard"], version = "0.21.1"}
[tool.poetry.group.dev.dependencies]
jupyter = "^1.0.0"
pytest = "^7.4.2"
pytest-cov = "^4.1.0"
pytest-mock = "^3.11.1"
pytest-asyncio = "^0.21.1"
pytest-alembic = "^0.10.7"
polyfactory = "^2.9.0"
schemathesis = "^3.18.0"
starlette-testclient = "0.2.0"
The text was updated successfully, but these errors were encountered: