-
-
Notifications
You must be signed in to change notification settings - Fork 461
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
Implemented the oauth2 integration between FastAPI and Authlib #278
base: master
Are you sure you want to change the base?
Conversation
This is an example of OpenID Connect 1.0 server in FastAPI and Authlib. https://github.com/gmachado-nextreason/example-oidc-server-fastapi |
It is impossible to implement FastAPI OAuth providers for now. Because FastAPI is async, Authlib is not ready for async providers. This should be done in v2.0. |
Thanks for quick review @lepture. Although FastAPI supports third party non async libraries: "If you are using a third party library that communicates with something (a database, an API, the file system, etc) and doesn't have support for using await, (this is currently the case for most database libraries), then declare your path operation functions as normally, with just def" As you can see on the routes.py example, I created all the endpoints without async: This is just a proposed integration solution between FastAPI and Authlib without async. I'm aware authlib only supports async for client not server yet (#63), just wanted to provide more options if anyone else is interested. Please let me know if it is still not the case. Glad to help anyhow. |
@gmachado-nextreason Yes, you are correct. We can support sync mode at first. But I won't add it in v0.15, how about adding it to v1.0. There are still works to do:
|
… FastAPI integration
Removed deprecated code and added the test cases scenarios. @lepture can you please review it again once you have a chance? |
"""Implementation of authlib.oauth2.rfc6749.AuthorizationServer class for FastAPI.""" | ||
|
||
import json | ||
from werkzeug.utils import import_string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not a good idea to import werkzeug
for FastAPI.
I'll merge and refactor the code later. I'm working on other stuff right now. |
@lepture resolved the conflict on tox.ini file, it is ready for you to merge. Thank you. |
Will this be merged? I'm interested in using/contributing to this. |
c4d90b8
to
8988b40
Compare
Any updates on this PR? FastAPI integration (sync or async) would be a nice addon. |
I'm not sure if this will get merged. I would like to make it a separate package since I have a plan to move Flask and Django integrations into separate packages in v2.0. For FastAPI, it is better to support async mode, but currently Authlib only has sync mode. I'll make it async in v2.0 too. In this case, I wonder if it is a good idea to have this PR (FastAPI) as built-in OAuth provider. |
It is better to focus not on FastAPI support, but on Starlette, because FastAPI is based on Starlette. |
Hey! Still relevant. |
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)