by foo101 · 9y ago · 0 comments
In other words, my question is: Why do you need to split the token at all? Why not store the hash of the entire token in the database?
So now, the username of the user becomes the selector, and the token becomes the verifier. What is wrong with this simpler approach?
This is advantageous because such a change could be implemented without invalidating existing tokens.
> What is wrong with this simpler approach?
Now you're requiring two pieces of data where the connecting user agent only sends one. If the client is a piece of software, you're imposing a maintenance burden on them to use the new approach.
What you're calling a "convoluted" scheme ensures a smooth transition. Better security with no compatibility breaks.
SELECT tokenid, userid FROM password_reset_tokens WHERE hashed_token = :hashed_token AND NOW() < expire_time
If you are worried that two tokens may collide to have the same hash, well that problem is there with your split-token solution too where token1 and token2 may collide such that token1 and token2 have the same selector and the same hash(verifier).