Allow for dynamic expiration checking with password reset tokens
- Dominant language
- No language data
- Stars
- 188
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
### Code of Conduct
- [x] I agree to follow Django's Code of Conduct
### Feature Description
Add a way to override the timeout when checking tokens in `PasswordResetTokenGenerator`.
### Problem
While `PASSWORD_RESET_TIMEOUT` is sufficient for most use cases in terms of token expiration there are some situations where an app may want to change that limit (e.g. new users). As such it is useful to have a way to modify that behavior without needing to inherit + re-write the `check_token` logic or modify the contents of tokens.
### Request or proposal
request
### Additional Details
_No response_
### Implementation Suggestions
There are a few ways I see this being useful:
1) add an optional timeout parameter to `check_token` that would override `settings.PASSWORD_RESET_TIMEOUT` if present
2) expose the current expiration logic in `check_token` as a separate method and make it safe to override (e.g. `is_token_expired(user, timestamp)`)
3) add a component to `PasswordResetTokenGenerator` which specifically handles validating the token expiration and move the current logic there
The first two should be fairly quick and easy to implement and would not break existing tokens on rollout or run into unnecessary security risks. The latter is a bit more robust but also more work and likely an unnecessary complication.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.