Skip to content

Commit 21acc7b

Browse files
authored
Merge pull request rails#45425 from shouichi/message-verifier-doc
Document urlsafe option of MessageVerifier [skip ci]
2 parents dc1df91 + 3234863 commit 21acc7b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

activesupport/lib/active_support/message_verifier.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,17 @@ module ActiveSupport
107107
# Though the above would most likely be combined into one rotation:
108108
#
109109
# verifier.rotate(old_secret, digest: "SHA256", serializer: Marshal)
110+
#
111+
# === Generating urlsafe strings
112+
#
113+
# By default MessageVerifier generates RFC 4648 complient strings which are
114+
# not urlsafe. In other words, they can contain "+" and "/". If you want to
115+
# generate urlsafe strings (complie with “Base 64 Encoding with URL and
116+
# Filename Safe Alphabet” in RFC 4648), you can pass urlsafe upon
117+
# initialization:
118+
#
119+
# @verifier = ActiveSupport::MessageVerifier.new("secret", urlsafe: true)
120+
# @verifier.generate("signed message") #=> "urlsafe_string"
110121
class MessageVerifier
111122
prepend Messages::Rotator::Verifier
112123

0 commit comments

Comments
 (0)