diff --git a/docs/configuration/authentication/strategies/jwt.md b/docs/configuration/authentication/strategies/jwt.md index 4f1d1f37..1591af84 100644 --- a/docs/configuration/authentication/strategies/jwt.md +++ b/docs/configuration/authentication/strategies/jwt.md @@ -16,7 +16,7 @@ def get_jwt_strategy() -> JWTStrategy: As you can see, instantiation is quite simple. It accepts the following arguments: * `secret` (`Union[str, pydantic.SecretStr]`): A constant secret which is used to encode the token. **Use a strong passphrase and keep it secure.** -* `lifetime_seconds` (`int`): The lifetime of the token in seconds. +* `lifetime_seconds` (`Optional[int]`): The lifetime of the token in seconds. Can be set to `None` but in this case the token will be valid **forever**; which may raise serious security concerns. * `token_audience` (`Optional[List[str]]`): A list of valid audiences for the JWT token. Defaults to `["fastapi-users:auth"]`. !!! tip "Why it's inside a function?" diff --git a/fastapi_users/authentication/strategy/jwt.py b/fastapi_users/authentication/strategy/jwt.py index 2c5b6095..4ace31ff 100644 --- a/fastapi_users/authentication/strategy/jwt.py +++ b/fastapi_users/authentication/strategy/jwt.py @@ -16,7 +16,7 @@ class JWTStrategy(Strategy, Generic[models.UC, models.UD]): def __init__( self, secret: SecretType, - lifetime_seconds: int, + lifetime_seconds: Optional[int], token_audience: List[str] = ["fastapi-users:auth"], ): self.secret = secret