rack-session-smart_cookie 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +14 -10
- data/lib/rack/session/smart_cookie.rb +4 -2
- data/lib/rack/session/smart_cookie/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e682138e9aecc0f8acefb54f729c959536974345
|
4
|
+
data.tar.gz: 681900b1c6f1305a3e9bea1a8373de8715916ed6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 881d18f4b0f1dfd52990d6e850c6c7661ca2901632e4082b8ce71f75b8afe791f01847f8ed3d7697532bd40c4a60892c9d66dbc64d42ed70124e7f6d48f579fa
|
7
|
+
data.tar.gz: 4a581360b1a4ba190134cd6dc9211fe11c030cfd582789645702bffb54e4b4b78276082642da1a5c3cce8216ac75c26a761b2eae8bb4b0f017abbcea24777278
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -43,10 +43,10 @@ serialized and stringified (in the case of the session payload) or merely
|
|
43
43
|
stringified (in the case of the digest).
|
44
44
|
|
45
45
|
The other key realization is that the method Rack uses to escape cookie data
|
46
|
-
([URI.encode_www_form_component][5]) will only ever allow URL-safe
|
47
|
-
period (`.`) and asterisk (`*`), so there's no sense in using any
|
48
|
-
stringification scheme other than URL-safe Base64! It doesn't need
|
49
|
-
configurable. The serializer remains configurable as the `:coder`.
|
46
|
+
([URI.encode_www_form_component][5]) will only ever allow non-padded, URL-safe
|
47
|
+
Base64 plus period (`.`) and asterisk (`*`), so there's no sense in using any
|
48
|
+
stringification scheme other than non-padded, URL-safe Base64! It doesn't need
|
49
|
+
to be configurable. The serializer remains configurable as the `:coder`.
|
50
50
|
|
51
51
|
The remaining differences are mostly just better defaults: MessagePack and
|
52
52
|
SHA2.
|
@@ -77,19 +77,23 @@ $ gem install rack-session-smart_cookie
|
|
77
77
|
use Rack::Session::SmartCookie
|
78
78
|
```
|
79
79
|
|
80
|
-
Rack::Session::SmartCookie
|
81
|
-
|
82
|
-
should *not* perform
|
80
|
+
Rack::Session::SmartCookie is a sub-class of [Rack::Session::Cookie][6] and
|
81
|
+
accepts all the same options. If you choose to override the default `:coder`,
|
82
|
+
it should *not* perform Base64 encoding or decoding.
|
83
83
|
|
84
|
-
|
84
|
+
The default `:coder` registers Symbol as a custom type on the factory. You can
|
85
|
+
easily register additional custom types like so:
|
85
86
|
|
86
87
|
```ruby
|
87
|
-
my_coder = Rack::Session::SmartCookie::MessagePack.new
|
88
|
-
|
88
|
+
my_coder = Rack::Session::SmartCookie::MessagePack.new do |factory|
|
89
|
+
factory.register_type(0x00, MyCustomType) # 0x60..0xFF are reserved
|
90
|
+
end
|
89
91
|
|
90
92
|
use Rack::Session::SmartCookie, :coder=>my_coder
|
91
93
|
```
|
92
94
|
|
95
|
+
Please see the [MessagePack][3] documentation for more details.
|
96
|
+
|
93
97
|
## Comparisons
|
94
98
|
|
95
99
|
For general size and performance benchmarks of the encoding schemes, see
|
@@ -55,10 +55,12 @@ module Rack
|
|
55
55
|
# Create our own factory so we don't pollute the global namespace
|
56
56
|
# with our custom type.
|
57
57
|
@factory = ::MessagePack::Factory.new
|
58
|
-
|
58
|
+
|
59
|
+
# MessagePack gets custom types 0x80..0xFF
|
59
60
|
# we get 0x60...0x80
|
60
|
-
# MessagePack gets 0x80..0xFF
|
61
61
|
@factory.register_type(0x60, Symbol)
|
62
|
+
# user gets 0x00...0x60
|
63
|
+
yield @factory if block_given?
|
62
64
|
end
|
63
65
|
|
64
66
|
def encode(data)
|