[11.x] allow for multiple providers in password reset table #53169
+44
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I am currently building an application with multiple authentication "providers" and "guards" for the first time.
When setting up my password resets, it seem like the intent is to have multiple tables, one for each "provider". However, it seems like we could easily handle multiple providers in a single table and ensure no collisions by adding a
provider
column.In order to accomplish this in a non-breaking way (due to the required migration), I use an optional boolean
multiple
key in theauth.passwords.{name}
config. Setting this totrue
will indicate to theDatabaseTokenRepository
aprovider
field has been added to thepassword_reset_tokens
table. When either selecting or inserting rows into this table, theDatabaseTokenRepository
will now conditionally check theprovider
column as well.If the
multiple
key is omitted or set tofalse
, theDatabaseTokenRepository
will behave as before, and only check against the email address.This would be an example auth config:
This would be the new migration:
Another option I played around with for checking table schema compatibility is querying the table schema when constructing the
DatabaseTokenRepository
. this works and is more automatic, but it obviously costs us an extra query. if that tradeoff is okay, I could switch back to it.