Skip to content

Conversation

browner12
Copy link
Contributor

if a user does not decide to use a dedicated cache store for their password resets, there's a risk of collision/overwriting of the cache keys in the default cache store, since we are just using the user's email. this allows the user to set an optional config value to use a prefix on the cache key.

I left the default blank to start, but we could also choose to come up with some default string.

the other option to this PR is to force people to use a dedicated cache store, which I think we should at least strongly encourage for other reasons as well.

if a user does not decide to use a dedicated cache store for their password resets, there's a risk of collision/overwriting of the cache keys in the default cache store, since we are just using the user's email.  this allows the user to set an optional config value to use a prefix on the cache key.
@taylorotwell taylorotwell merged commit f405bf0 into laravel:11.x Nov 9, 2024
31 checks passed
@taylorotwell
Copy link
Member

Would it not be a bit easier to just put them in the cache as something like password-reset-.sha1($email)?

@browner12
Copy link
Contributor Author

having some low-collision chance default seems fine to me

@browner12 browner12 deleted the AB-password-cache-prefix branch June 24, 2025 17:54
browner12 added a commit to browner12/framework that referenced this pull request Jun 24, 2025
this is mostly a rollback of laravel#53448 per Taylor's request. rather than allowing an optional prefix, we'll use a deterministic hash of the user's email for our cache key.  this should make the chance of a collision if no dedicated store is used statistically insignificant.

I've also opted to extract out a `makeCacheKey()` method here mainly to reduce the duplicated code and help prevent bugs from divergence. however, this could possibly help userland override the cache key generation. maybe I'm overthinking that, maybe it's honestly not a problem.
taylorotwell added a commit that referenced this pull request Jun 25, 2025
* remove the "prefix" option for cache password resets

this is mostly a rollback of #53448 per Taylor's request. rather than allowing an optional prefix, we'll use a deterministic hash of the user's email for our cache key.  this should make the chance of a collision if no dedicated store is used statistically insignificant.

I've also opted to extract out a `makeCacheKey()` method here mainly to reduce the duplicated code and help prevent bugs from divergence. however, this could possibly help userland override the cache key generation. maybe I'm overthinking that, maybe it's honestly not a problem.

* formatting

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
mohammad-fouladgar pushed a commit to mohammad-fouladgar/framework that referenced this pull request Jul 22, 2025
…56127)

* remove the "prefix" option for cache password resets

this is mostly a rollback of laravel#53448 per Taylor's request. rather than allowing an optional prefix, we'll use a deterministic hash of the user's email for our cache key.  this should make the chance of a collision if no dedicated store is used statistically insignificant.

I've also opted to extract out a `makeCacheKey()` method here mainly to reduce the duplicated code and help prevent bugs from divergence. however, this could possibly help userland override the cache key generation. maybe I'm overthinking that, maybe it's honestly not a problem.

* formatting

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants