49 Commits

Author SHA1 Message Date
caa17889e1 Drop Python 3.8 support 2024-11-03 12:51:32 +00:00
72aa68c462 Native model and generic ID (#971)
* Use a generic Protocol model for User instead of Pydantic

* Remove UserDB Pydantic schema

* Harmonize schema variable naming to avoid confusions

* Revamp OAuth account model management

* Revamp AccessToken DB strategy to adopt generic model approach

* Make ID a generic instead of forcing UUIDs

* Improve generic typing

* Improve Strategy typing

* Tweak base DB typing

* Don't set Pydantic schemas on FastAPIUsers class: pass it directly on router creation

* Add IntegerIdMixin and export related classes

* Start to revamp doc for V10

* Revamp OAuth documentation

* Fix code highlights

* Write the 9.x.x ➡️ 10.x.x migration doc

* Fix pyproject.toml
2022-05-05 14:51:19 +02:00
533504634f Improve dependencies typing 2022-01-15 11:08:49 +01:00
e6125905e0 Fix #865 (#866)
* Fix #865

* Add # pragma: no cover to all try blocks

* Fix same issue with root module
2022-01-15 10:50:06 +01:00
dade8c263d Revamp implementation with a manager layer and db class as dependency callable 2021-09-14 11:12:34 +02:00
848315badc Remove DB dependencies (#704)
* Remove database adapter in favor of external dependencies

* Prevent flit from installing all optional dependencies when testing build

* Remove MongoDB service during CI build
2021-08-27 17:01:50 +02:00
728c160b50 Added python_type into GUID (#648) 2021-06-25 16:45:31 +02:00
a690e82408 Fix typing errors 2021-05-17 09:00:34 +02:00
3ac67377cb Fix #600: revamp Tortoise/Pydantic interaction (#612) 2021-04-20 14:46:36 +02:00
5258c24762 Apply black 2021-03-04 17:50:37 +01:00
48d9a399e0 Fix type errors 2021-02-07 09:58:52 +01:00
579313f887 Ormar backend support (#470)
* Add db adapter for ormar (wip)

* finish ormar support enough to pass tests

* remove idea folder

* update ormar version in tool.flit.metadata.requires-extra

* Add documentation about ormar

* Apply isort and black formatting

* Restore python 3.7 in Pipfile

* Update build.yml

* Add missing test for ormar update

* changes after review

Co-authored-by: Paolo Dina <paolo.dina@codingmoth.com>
Co-authored-by: collerek <collerek@gmail.com>
2021-02-07 09:34:40 +01:00
2829824a95 Fix #438: issue while retrieving OAuth accounts with PSQL 2021-01-12 10:53:40 +01:00
373157c284 Finalize user activation feature (#439)
* Add routes for user activation (#403)

* Add routes for user activation

Generate a token after creating the user in register route, passing to `activation_callback`, if `activation_callback` supplied
Create new `/activate` route that will verify the token and activate the user
Add new error codes to `fastapi_users/router/common.py`
Update documentation
Add tests

Co-authored-by: Mark Todd <markpeter.todd@hotmail.co.uk>

* Rework routes for user activation

* Separate verification logic and token generation into `/fastapi_users/router/verify.py`, with per-route callbacks for custom behaviour

* Return register router to original state

* Added `is_verified` property to user models

* Added `requires_verification` argument to `get_users_router`and `get_auth_router`

* Additional dependencies added for verification in `fastapi_users/authentication/__init__.py`

* Update tests for new behaviour

* Update `README.md` to describe a workaround for possible problems during testing, by exceeding ulimit file descriptor limit

Co-authored-by: Mark Todd <markpeter.todd@hotmail.co.uk>

* Restored docs to original state.

* All other modifications reqested added

Kebab-case on request-verify-token
SECRET now used as test string
Other minor changes

Co-authored-by: Mark Todd <markpeter.todd@hotmail.co.uk>

* Embed token in body in verify route

* Reorganize checks in verify route and add unit test

* Ignore coverage on Protocol classes

* Tweak verify_user function to take full user in parameter

* Improve unit tests structure regarding parametrized test client

* Make after_verification_request optional to be more consistent with other routers

* Tweak status codes on verify routes

* Write documentation for verification feature

* Add not released warning on verify docs

Co-authored-by: Edd Salkield <edd@salkield.uk>
Co-authored-by: Mark Todd <markpeter.todd@hotmail.co.uk>
2021-01-12 10:44:42 +01:00
7cf7154e27 Fix #431: make OAuth expires_at optional in model and DB schemas 2020-12-28 08:59:27 +01:00
97cc799737 Add SQL String length in SQLAlchemy for MySQL compatibility 2020-09-30 14:48:51 +02:00
6334a4b911 Fix #261: improve email query in MongoDB 2020-07-20 16:18:53 +02:00
b7dbdf6ea6 Fix #245 : handle email as case insensitive while retrieving user in DB (#250)
* Add unit tests to enforce email case insensitivity

* Handle email as case insentitive while retrieving user in DB

* Apply isort/black

* Add migration doc
2020-07-09 18:44:25 +02:00
0a0dcadfdc Use real UUID for User id. and OAuthAccount id. (#198)
* Use UUID for user id and oauth account id

* Update documentation for UUID

* Tweak GUID definition of SQLAlchemy to match Tortoise ORM one

* Write migration doc
2020-05-21 16:40:33 +02:00
a9ee467518 Remove list endpoint and related methods 2020-04-25 11:46:20 +02:00
639217bb08 Make unit tests full async (#160)
* Bump pytest-asyncio from 0.10.0 to 0.11.0

Bumps [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) from 0.10.0 to 0.11.0.
- [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases)
- [Commits](https://github.com/pytest-dev/pytest-asyncio/compare/v0.10.0...v0.11.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Bump pytest-asyncio from 0.10.0 to 0.11.0

Bumps [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) from 0.10.0 to 0.11.0.
- [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases)
- [Commits](https://github.com/pytest-dev/pytest-asyncio/compare/v0.10.0...v0.11.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Convert tests to full async

* Change deprecated yield_fixture

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: François Voron <fvoron@gmail.com>
2020-04-25 11:34:11 +02:00
e58f18582e Fix tortoise import error (#97)
I was getting an import error using tortoise 0.1.1: `ImportError: cannot import name 'Model' from 'tortoise'`.  These few changes seemed to have resolved the issue.
2020-02-05 09:20:28 +01:00
88b133d41c Implement OAuth2 flow (#88)
* Move users router in sub-module

* Factorize UserRouter into EventHandlersRouter

* Implement OAuth registration/login router

* Apply isort/black

* Remove temporary pytest marker

* Fix httpx-oauth version in lock file

* Ensure ON_AFTER_REGISTER event is triggered on OAuth registration

* Add API on FastAPIUsers to generate an OAuth router

* Improve test coverage of FastAPIUsers

* Small fixes

* Write the OAuth documentation

* Fix SQL unit-tests by avoiding collisions in SQLite db files
2020-01-17 11:43:17 +01:00
104a6c6bf5 Inject every models variations and DB model in DB adapters (#84)
* Inject every model variations in router and DB model in DB adapters

* Update documentation and import Tortoise in db module

* Use path operation decorator dependencies for superuser routes
2020-01-04 15:36:34 +01:00
7817d372c6 Fix #77: use CharField for PK in Tortoise adapter 2019-12-17 15:49:30 +01:00
b5b0bbbb01 Tortoise ORM support (#59)
* add tortoise to dependencies

* add tortoise as optional dependency in pyproject.toml

* add tortoise support (tests needed)

* Add tortoise support (also defined orm_mode in pydantic model

* tests for tortoise support

* format by black

* docs for tortoise

* delete type annotations

* delete underscore

* do it in 1 line

* add 1 line before yield

* fix in docs

* fix bug and add annotation for test

* Tweak documentation and fix Tortoise error about id update

* Improve Tortoise coverage by using get instead of filter

* Fix Pipfile.lock
2019-12-03 21:24:27 +01:00
9aa8398884 Do a proper Pydantic model instantation in SQLAlchemy adapter 2019-11-17 09:59:44 +01:00
60c815e425 Fix #35: catch import error when not having optional DB depedencies 2019-10-31 21:43:29 +01:00
9b7ec58800 #21: Add superuser routes (#30)
* Add CRU superuser routes

* Add delete method on DB adapters

* Add superuser delete route

* Add superuser routes documentation

* Pass black formatter
2019-10-29 13:32:44 +01:00
ab0b187f20 Implement MongoDB database adapter (#29)
* Implement MongoDB adapter using motor

* Add mongo container to build pipeline

* Tidy up dependencies

* Update documentation for MongoDB

* Export MongoDB adapter from db package

* Pass black format

* Update README
2019-10-27 16:34:30 +01:00
3875632c80 Run the anti-timing attack hash only when user is None 2019-10-25 09:10:30 +02:00
089d088268 Fix Deepsource issues (#22)
* Fix Deepsource issues

* Add docs/ to Deepsource exclusion list

* Fix black formatting
2019-10-20 16:16:52 +02:00
f2892aa378 #5 Improve test coverage (#6)
* Improve test coverage of BaseUserDatabase

* Improve unit test isolation

* Improve coverage of router and authentication
2019-10-15 07:54:53 +02:00
f3b7fa662a Ensure columns in SQL schema are not nullable 2019-10-11 13:08:03 +02:00
ef796abb55 Reorganize base modules 2019-10-10 19:21:36 +02:00
ef6dd2c39c Implement user-facing API 2019-10-10 18:55:11 +02:00
0112e700ac Improve typing and make User pydantic models dynamic 2019-10-10 13:37:52 +02:00
9f41a8b9a7 Use a Base table class for SQLAlchemy adapter 2019-10-09 18:03:10 +02:00
d781a41872 Install Black formatter 2019-10-09 16:52:06 +02:00
f6ff897232 Setup Mkdocs 2019-10-09 08:07:49 +02:00
96685c7696 Rename SQLAlchemy User table to BaseUser 2019-10-09 07:22:58 +02:00
06dd8ad22e Implement JWT authentication 2019-10-08 17:18:38 +02:00
20aa806375 Rename DB classes 2019-10-07 17:34:12 +02:00
51b67b0739 Add get by id method on DB adapter 2019-10-07 07:53:56 +02:00
c4ff6ca3fe Implement password hash migration 2019-10-07 07:50:19 +02:00
20bb285f03 Use built-in OAuth2PasswordRequestForm for login 2019-10-06 14:02:42 +02:00
a81b438ec9 Implement authentication mechanism 2019-10-06 11:53:42 +02:00
bcc88a8b14 Implement working SQLAlchemy DB adapter 2019-10-06 11:00:24 +02:00
552f313d76 Add database abstraction 2019-10-06 08:53:13 +02:00