[ci skip] Improve ActiveSupport::MessageVerifier and ActiveRecord::SignedId docs #52064
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.
Motivation / Background
The documentation on
ActiveSupport::MessageVerifier
uses “sensitive data” string as an example of a message to sign/verify; that wording might induce the developer to think we’re dealing with encryption, while the payload is actually only Base64 encoded so it's actually cleartext and can be decoded by anyone.Actually, the fact that the signed string is base64 encoded and that the
MessageVerifier
works with "keys" (the current docs even state about Key Rotation) might further cause the wrong impression in the developer that there's some encryption going on, whilst there is absolutely none.We add a reference to
MessageEncryptor
to let the developer knows that, if he needs the payload to be encrypted, Rails already has that taken care of.Finally, we also improve the documentation on
ActiveRecord::SignedId
, which usesMessageVerifier
and thereby will also expose the ID as encoded cleartext; we make it explicit that it’s not encryption, only signing, so the ID, albeit tamper proof, will be able to be read in cleartext by anyone.Additional information
While working on this, I felt the desire to have
ActiveRecord::EncryptedId
.It would behave just like
ActiveRecord::SignedId
does, but it would useMessageEncryptor
instead ofMessageVerifier
, so that the IDs would never be exposed.The API would respect the parity, so we would have
user.encrypted_id
andUser.find_encrypted(encrypted_id)
.I recently opened issue #52063 to discuss the last missing piece that I would use to implement
ActiveRecord::EncryptedId
; I know this PR is just regarding documentation, but if any members could indicate if a PR forActiveRecord::EncryptedId
had a chance of being accepted I would start working on it as soon as I could spare the time.Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]