macaroons 0.5.3 → 0.6.0
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/lib/macaroons/raw_macaroon.rb +1 -1
- data/lib/macaroons/serializers/json.rb +23 -8
- data/lib/macaroons/verifier.rb +1 -1
- data/lib/macaroons/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd23deb2d08621d3bbcfeef61d2f7794449edfdf
|
4
|
+
data.tar.gz: 3eba43c3203ba0ab589d7485fdf94dece7139be7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9758e651d2904b58c0d7983b854699dff193e83741e711e34b344007554cfd9730e10cda29869e09a21f178418c4b471d3360c93ef047008598adee2f8f883cf
|
7
|
+
data.tar.gz: 8abda61eb01699323fd8b4e11462ac0997af03e624d98c82690b65ef99e59b83f4f9aaf109c1d83adcd43ff180a1b205a8aa637a7ec1c81f0eb8f8588f0b366d
|
@@ -51,7 +51,7 @@ module Macaroons
|
|
51
51
|
truncated_or_padded_signature = Utils.truncate_or_pad(@signature)
|
52
52
|
box = RbNaCl::SimpleBox.from_secret_key(truncated_or_padded_signature)
|
53
53
|
ciphertext = box.encrypt(derived_caveat_key)
|
54
|
-
verification_id =
|
54
|
+
verification_id = ciphertext
|
55
55
|
caveat = Caveat.new(caveat_id, verification_id, caveat_location)
|
56
56
|
@caveats << caveat
|
57
57
|
@signature = Utils.sign_third_party_caveat(@signature, verification_id, caveat_id)
|
@@ -4,20 +4,35 @@ module Macaroons
|
|
4
4
|
class JsonSerializer
|
5
5
|
|
6
6
|
def serialize(macaroon)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
caveats = macaroon.caveats.map! do |c|
|
8
|
+
if c.first_party?
|
9
|
+
c
|
10
|
+
else
|
11
|
+
Macaroons::Caveat.new(
|
12
|
+
c.caveat_id,
|
13
|
+
verification_id=Base64.strict_encode64(c.verification_id),
|
14
|
+
caveat_location=c.caveat_location
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
serialized = {
|
19
|
+
location: macaroon.location,
|
20
|
+
identifier: macaroon.identifier,
|
21
|
+
caveats: caveats.map(&:to_h),
|
22
|
+
signature: macaroon.signature
|
23
|
+
}
|
24
|
+
MultiJson.dump(serialized)
|
14
25
|
end
|
15
26
|
|
16
27
|
def deserialize(serialized)
|
17
28
|
deserialized = MultiJson.load(serialized)
|
18
29
|
macaroon = Macaroons::RawMacaroon.new(key: 'no_key', identifier: deserialized['identifier'], location: deserialized['location'])
|
19
30
|
deserialized['caveats'].each do |c|
|
20
|
-
|
31
|
+
if c['vid']
|
32
|
+
caveat = Macaroons::Caveat.new(c['cid'], Base64.strict_decode64(c['vid']), c['cl'])
|
33
|
+
else
|
34
|
+
caveat = Macaroons::Caveat.new(c['cid'], c['vid'], c['cl'])
|
35
|
+
end
|
21
36
|
macaroon.caveats << caveat
|
22
37
|
end
|
23
38
|
macaroon.signature = Utils.unhexlify(deserialized['signature'])
|
data/lib/macaroons/verifier.rb
CHANGED
@@ -97,7 +97,7 @@ module Macaroons
|
|
97
97
|
def extract_caveat_key(signature, caveat)
|
98
98
|
key = Utils.truncate_or_pad(signature)
|
99
99
|
box = RbNaCl::SimpleBox.from_secret_key(key)
|
100
|
-
decoded_vid =
|
100
|
+
decoded_vid = caveat.verification_id
|
101
101
|
box.decrypt(decoded_vid)
|
102
102
|
end
|
103
103
|
|
data/lib/macaroons/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: macaroons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Cordell
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-05-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multi_json
|