macaroons 0.5.3 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d07fa181e8d3635f3a78b6ec5a0f035a78e47039
4
- data.tar.gz: c46c2dc766e8836ddd6a2640019ffd324f57e4ae
3
+ metadata.gz: fd23deb2d08621d3bbcfeef61d2f7794449edfdf
4
+ data.tar.gz: 3eba43c3203ba0ab589d7485fdf94dece7139be7
5
5
  SHA512:
6
- metadata.gz: a7b9c6315958a34426c6baa7433fe160b6578c941a1e78bc02f0c9d7e40207b1794dcc3d116641eeb06d6c8ab5277d8f05a5d827a22f901a0e7fdaef273cdf80
7
- data.tar.gz: 4e4af568b519100222649890723faf18d789efb73e50651ddbdbd0bc9b6bc87665e14643f114b5370684905c30af0072c66b5c52eeb4b3d76f8630fba5b72b84
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 = Base64.strict_encode64(ciphertext)
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
- serialized = {
8
- location: macaroon.location,
9
- identifier: macaroon.identifier,
10
- caveats: macaroon.caveats.map!(&:to_h),
11
- signature: macaroon.signature
12
- }
13
- MultiJson.dump(serialized)
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
- caveat = Macaroons::Caveat.new(c['cid'], c['vid'], c['cl'])
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'])
@@ -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 = Base64.strict_decode64(caveat.verification_id)
100
+ decoded_vid = caveat.verification_id
101
101
  box.decrypt(decoded_vid)
102
102
  end
103
103
 
@@ -1,3 +1,3 @@
1
1
  module Macaroons
2
- VERSION = '0.5.3'
2
+ VERSION = '0.6.0'
3
3
  end
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.5.3
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-03-09 00:00:00.000000000 Z
13
+ date: 2015-05-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json