mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2025-08-15 11:11:16 +08:00
Allow lifetime_seconds=None (#835)
This commit is contained in:
@ -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?"
|
||||||
|
@ -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
|
||||||
|
Reference in New Issue
Block a user