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

@ -14,7 +14,7 @@ from fastapi_users.authentication.transport import (
from fastapi_users.types import DependencyCallable
class AuthenticationBackend(Generic[models.UC, models.UD]):
class AuthenticationBackend(Generic[models.UP]):
"""
Combination of an authentication transport and strategy.
@ -33,7 +33,7 @@ class AuthenticationBackend(Generic[models.UC, models.UD]):
self,
name: str,
transport: Transport,
get_strategy: DependencyCallable[Strategy[models.UC, models.UD]],
get_strategy: DependencyCallable[Strategy[models.UP, models.ID]],
):
self.name = name
self.transport = transport
@ -41,8 +41,8 @@ class AuthenticationBackend(Generic[models.UC, models.UD]):
async def login(
self,
strategy: Strategy[models.UC, models.UD],
user: models.UD,
strategy: Strategy[models.UP, models.ID],
user: models.UP,
response: Response,
) -> Any:
token = await strategy.write_token(user)
@ -50,8 +50,8 @@ class AuthenticationBackend(Generic[models.UC, models.UD]):
async def logout(
self,
strategy: Strategy[models.UC, models.UD],
user: models.UD,
strategy: Strategy[models.UP, models.ID],
user: models.UP,
token: str,
response: Response,
) -> Any: