Allow lifetime_seconds=None (#835)

This commit is contained in:
David Brochart
2022-01-03 12:05:55 +01:00
committed by GitHub
parent d469bace6e
commit 79557eead4
2 changed files with 2 additions and 2 deletions

View File

@ -16,7 +16,7 @@ def get_jwt_strategy() -> JWTStrategy:
As you can see, instantiation is quite simple. It accepts the following arguments: 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.** * `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"]`. * `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?" !!! tip "Why it's inside a function?"

View File

@ -16,7 +16,7 @@ class JWTStrategy(Strategy, Generic[models.UC, models.UD]):
def __init__( def __init__(
self, self,
secret: SecretType, secret: SecretType,
lifetime_seconds: int, lifetime_seconds: Optional[int],
token_audience: List[str] = ["fastapi-users:auth"], token_audience: List[str] = ["fastapi-users:auth"],
): ):
self.secret = secret self.secret = secret