The random key generated by the randomizer is not used in the “KEY” parameter in the url, it is the key to encode and decode the Encrypted hashed old password…
The “KEY” parameter in the url is an “ENCRYPTED” hashed old password… Since it is encrypted, it means it needs a “KEY” to be decrypted, and that’s where the “Key Randomizer” comes in and the result randomized key is stored in “kirby/.htresetkey”…
I believe that is not a security problem, however if you’re really sure what you meant, then you can add a pull request in github for me to test it… I have a code summary for you to easily understand the whole code…
PS: I am really sorry, I am really not fun of commenting and indenting my codes…
Code Summary
Before everything runs, the php script checks if the file “kirby/.htresetkey” is existing, if it exists and contains 8 alphanumeric characters then it continues the script and returns the client a send email using username form to fill-up, if it doesn’t exist it creates the file and generates a 8 character randomized alphanumeric string to be written on the file and returns the client a send email using username form to fill-up…
After the client sends the username with the form using the POST method, the server side script automatically process it by checking if the username exists and has a valid email address associated with it, if it doesn’t then the script returns an error to the client… After the email address has been validated, the script generates a “key” and a “token”… The “KEY” will be used to be the value of the key parameter, the “KEY” is generated by encrypting (The key in encrypting it is the 8 character alphanumeric string inside the kirby/.htresetkey file) the old hashed password… The “TOKEN” will be used to be the value of the token parameter, the “TOKEN” is generated by encrypting (The key in encrypting it is the 8 character alphanumeric string inside the kirby/.htresetkey file) current time or TIMESTAMP… After “KEY” and “TOKEN” is generated, it will be attached to the Reset Password URL that will be emailed to you… So the format of the reset link would be http://example.com/forgot.php?username=%USERNAME%&key=%ENCRYPTED_OLD_PASSWORD%&token=%ENCRYPTED_TIMESTAMP%…
After the email containing the reset link has been sent to the client’s email address and the client clicks the reset link… This is what happens:
Before everything runs, the php script checks if the file “kirby/.htresetkey” is existing, if it exists and contains 8 alphanumeric characters then it continues the script and returns the client a NEW PASSWORD form to fill-up if it passed the requirements below, if it doesn’t exist, it creates the file and generates a 8 character randomized alphanumeric string to be written on the file and returns the client a NEW PASSWORD form to fill-up if it passed the requirements below…
Requirements:
- Username must exist… It is checked by searching for the file
$_GET[‘username’].“.php” that is stored in the kirby panel accounts folder…
- The encrypted value in the “KEY” parameter must be equal to the
hashed password in the $_GET[‘username’].“.php” that is stored in the
kirby panel accounts folder. It is checked by Decrypting (The key in decrypting it is the 8 character alphanumeric string inside the kirby/.htresetkey file) the encrypted value in the “KEY” parameter, after the value has been decrypted it will be compared to the old hashed password in the $_GET[‘username’].“.php” …if matched continue script, return error if otherwise…
- The encrypted value in the “TOKEN” parameter must not be 5 hours or
more old, otherwise it will invalidate the reset link… It is checked
by Decrypting (The key in decrypting it is the 8 character
alphanumeric string inside the kirby/.htresetkey file) the encrypted
value in the “TOKEN” parameter, after the value has been decrypted,
the hours have passed since the decrypted TIMESTAMP will be counted…
If less than 5 hours then continue script, return error if otherwise.
If the client has passed the requirements and sends the New Password with the form using the POST method rechecks the requirements above and if it passes again it will hash the NEW PASSWORD and write it in the $_GET[‘username’].“.php” that is stored in the
kirby panel accounts folder… If everything is fine, then the sript should return a message saying that “You may now login with your new password in kirby panel”…