mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2025-08-17 22:18:19 +08:00

* 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
28 lines
776 B
Python
28 lines
776 B
Python
import sys
|
|
from typing import Generic, Optional
|
|
|
|
if sys.version_info < (3, 8):
|
|
from typing_extensions import Protocol # pragma: no cover
|
|
else:
|
|
from typing import Protocol # pragma: no cover
|
|
|
|
from fastapi_users import models
|
|
from fastapi_users.manager import BaseUserManager
|
|
|
|
|
|
class StrategyDestroyNotSupportedError(Exception):
|
|
pass
|
|
|
|
|
|
class Strategy(Protocol, Generic[models.UP, models.ID]):
|
|
async def read_token(
|
|
self, token: Optional[str], user_manager: BaseUserManager[models.UP, models.ID]
|
|
) -> Optional[models.UP]:
|
|
... # pragma: no cover
|
|
|
|
async def write_token(self, user: models.UP) -> str:
|
|
... # pragma: no cover
|
|
|
|
async def destroy_token(self, token: str, user: models.UP) -> None:
|
|
... # pragma: no cover
|