diff --git a/fastapi_users/authentication/__init__.py b/fastapi_users/authentication/__init__.py index 8421596c..a152b145 100644 --- a/fastapi_users/authentication/__init__.py +++ b/fastapi_users/authentication/__init__.py @@ -7,6 +7,8 @@ from fastapi_users.models import BaseUserDB class BaseAuthentication: + """Base adapter for generating and decoding authentication tokens.""" + async def get_login_response(self, user: BaseUserDB, response: Response): raise NotImplementedError() diff --git a/fastapi_users/authentication/jwt.py b/fastapi_users/authentication/jwt.py index 99f9d282..60f1e20f 100644 --- a/fastapi_users/authentication/jwt.py +++ b/fastapi_users/authentication/jwt.py @@ -21,6 +21,12 @@ def generate_jwt(data: dict, lifetime_seconds: int, secret: str, algorithm: str) class JWTAuthentication(BaseAuthentication): + """ + Authentication using a JWT. + + :param secret: Secret used to encode the JWT. + :param lifetime_seconds: Lifetime duration of the JWT in seconds. + """ algorithm: str = "HS256" secret: str diff --git a/fastapi_users/models.py b/fastapi_users/models.py index e2660a6f..d84e921c 100644 --- a/fastapi_users/models.py +++ b/fastapi_users/models.py @@ -7,6 +7,8 @@ from pydantic.types import EmailStr class BaseUser(BaseModel): + """Base User model.""" + id: Optional[str] = None email: Optional[EmailStr] = None is_active: Optional[bool] = True @@ -31,6 +33,8 @@ class BaseUserDB(BaseUser): class Models: + """Generate models inheriting from the custom User model.""" + def __init__(self, user_model: Type[BaseUser]): class UserCreate(user_model, BaseUserCreate): # type: ignore pass diff --git a/fastapi_users/router.py b/fastapi_users/router.py index f091bd76..b0db5a2f 100644 --- a/fastapi_users/router.py +++ b/fastapi_users/router.py @@ -14,6 +14,7 @@ from fastapi_users.password import get_password_hash def get_user_router( user_db: BaseUserDatabase, user_model: Type[BaseUser], auth: BaseAuthentication ) -> APIRouter: + """Generate a router with the authentication routes.""" router = APIRouter() models = Models(user_model)