-
Notifications
You must be signed in to change notification settings - Fork 21.8k
Add Application#message_verifier method to return a message verifier #12995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
❤️ 💚 💛 |
yes, the name is sufficient, no need to second-handle the salt configuration anywhere else. Their sole purpose is to get different deterministic bytes out of the KeyGenerator |
# | ||
# This verify can be used to generate and verify signed messages in the application. | ||
# | ||
# It is recommended to not use the same verifier to different things, so you can get different |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not to
? And for different things
maybe.
Great bro 👍 |
I think you can just remove the whole notion of 'configured salts'. Whatever the user passes in can be the salt, e.g. Rails::Application.message_verifier("yo bro") |
Updated |
Rails.application.message_verifier.verify(message) | ||
# => 'my sensible data' | ||
|
||
It is recommended not not use the same verifier for different things, so you can get different |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not to
Seems great 👍 |
@NZKoz, can you do a final review and merge if we're kosher? |
My only comment would be to switch the documentation to always be passing a salt/name for the verifier, but that's nit picking. merge at will @rafaelfranca ! |
@NZKoz that make sense. I'll do it since I'll have to fix the conflics |
It is an application global verifier that can be used to generate and verify signed messages. See the documentation of ActiveSupport::MessageVerifier for more information.
Add Application#message_verifier method to return a message verifier
👍 |
This is awesome — nice work! Would a similar thing for |
@AquaGeek maybe. I'll take a look on this |
This verifier can be used to generate and verify signed messages in the application.
It is recommended to not use the same verifier to different things, so you can get different verifiers passing the name argument.
By default all the verifiers will share the same salt, so messages generated by one can be verifier by another one.
We recommend to use different salts to different verifiers and you can configure using
config.message_verifier_salts
.See the
ActiveSupport::MessageVerifier
documentation for more information.