mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2025-08-18 06:32:24 +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
33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
import sys
|
|
from datetime import datetime
|
|
from typing import Any, Dict, 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.authentication.strategy.db.models import AP
|
|
|
|
|
|
class AccessTokenDatabase(Protocol, Generic[AP]):
|
|
"""Protocol for retrieving, creating and updating access tokens from a database."""
|
|
|
|
async def get_by_token(
|
|
self, token: str, max_age: Optional[datetime] = None
|
|
) -> Optional[AP]:
|
|
"""Get a single access token by token."""
|
|
... # pragma: no cover
|
|
|
|
async def create(self, create_dict: Dict[str, Any]) -> AP:
|
|
"""Create an access token."""
|
|
... # pragma: no cover
|
|
|
|
async def update(self, access_token: AP, update_dict: Dict[str, Any]) -> AP:
|
|
"""Update an access token."""
|
|
... # pragma: no cover
|
|
|
|
async def delete(self, access_token: AP) -> None:
|
|
"""Delete an access token."""
|
|
... # pragma: no cover
|