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
This commit is contained in:
François Voron
2022-05-05 14:51:19 +02:00
committed by GitHub
parent b7734fc8b0
commit 72aa68c462
124 changed files with 2144 additions and 2114 deletions

View File

@ -3,19 +3,12 @@ import pytest
from fastapi import FastAPI, status
from fastapi_users.fastapi_users import FastAPIUsers
from tests.conftest import User, UserCreate, UserDB, UserUpdate
from tests.conftest import IDType, User, UserCreate, UserModel, UserUpdate
@pytest.fixture
def fastapi_users(get_user_manager, mock_authentication) -> FastAPIUsers:
return FastAPIUsers[User, UserCreate, UserUpdate, UserDB](
get_user_manager,
[mock_authentication],
User,
UserCreate,
UserUpdate,
UserDB,
)
return FastAPIUsers[UserModel, IDType](get_user_manager, [mock_authentication])
@pytest.fixture
@ -23,14 +16,14 @@ def test_app(
fastapi_users: FastAPIUsers, secret, mock_authentication, oauth_client
) -> FastAPI:
app = FastAPI()
app.include_router(fastapi_users.get_register_router())
app.include_router(fastapi_users.get_register_router(User, UserCreate))
app.include_router(fastapi_users.get_reset_password_router())
app.include_router(fastapi_users.get_auth_router(mock_authentication))
app.include_router(
fastapi_users.get_oauth_router(oauth_client, mock_authentication, secret)
)
app.include_router(fastapi_users.get_users_router())
app.include_router(fastapi_users.get_verify_router())
app.include_router(fastapi_users.get_users_router(User, UserUpdate))
app.include_router(fastapi_users.get_verify_router(User))
return app