-
-
Notifications
You must be signed in to change notification settings - Fork 161
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
feat: Add fastapi-users support #143
Conversation
Hi and thanks for your work! Instead of writing in docs that it works only with SQLAlchemy, please define is_hidden property. Like this: is_hidden=check_orm(['sqlalchemy']) After you do this, this entry will only show up if the chosen orm is SQLAlchemy. |
...e/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/db_sa/models/users.py
Outdated
Show resolved
Hide resolved
...e/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/db_sa/models/users.py
Show resolved
Hide resolved
...e/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/db_sa/models/users.py
Show resolved
Hide resolved
...e/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/db_sa/models/users.py
Outdated
Show resolved
Hide resolved
...e/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/db_sa/models/users.py
Show resolved
Hide resolved
...e/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/db_sa/models/users.py
Outdated
Show resolved
Hide resolved
As I see, you added all possible backends and it's really great. But the problem is that every time people choose an option to add users, they need to delete many lines. I suggest you a solution. You can add new menu if users are enabled. This would be a multiselect menu with options like:
I can help implementing it. Or you can do it yourself. |
@s3rius I can work on it no problem. I'll address the other points as well. Do you prefer single atomic commits on PR's? |
Hi, @andcarnivorous, you can do as you want. I'll sqash commits when it's merged. |
I have removed the google oauth stuff for now. Maybe I'll open another PR for that in the future just for it |
@andcarnivorous, thank you. Please tell me when the PR is ready for another review. |
any updates with this? |
Hey, really sorry, it's been a year busier than expected and completely forgot about this PR, I'll try to update it and finalize it in the following days! Sorry for forgetting about this |
Adds support to fastapi-users by adding the option to the menu and creating views for JWT, cookie and OAuth authentication. Adds user models and views. This is only compatible with SQLAlchemy.
Fastapi-users option depends on sqlalchemy, add multimenu for users backend type. Removes oauth with google for now. Removes unnecessary methods.
...plate/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/web/api/router.py
Outdated
Show resolved
Hide resolved
The users module is skipped from type checking since fastapi-users uses a series of classes that inherit from Generics which makes type hinting compliance with MyPy painful to work with.
I have opted for skipping the users module from mypy checks, the others seem to be mypy compliant and everything is fine with flake8. The reason for skipping the mypy checks in the users.py module is that fastapi-users provides classes that inherit from Generics and it seems to be a pain to manage to make them mypy compliant so far (never found myself having to deal with this type of thing, so if anyone knows how to approach this the right way please do). |
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.
How can I test this out?
- clone the repo
- git checkout andcarnivorous:master
- something something to execute fastapi_template
- enable
users
option during interactive setup
otherwise LGTM
|
You have to:
|
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.
The PR looks good.
@andcarnivorous, I truly grateful for your work. You've put so much effort into this. It's really hard to extend such templators. Thank you very very much. |
No problem! It was fun and glad it could contribute. |
Adds support to fastapi-users by adding the option to the menu and creating views for JWT, cookie and OAuth authentication. Adds user models and views. This is only compatible with SQLAlchemy.
Tested locally and users can be registered and log in works.