File tree 2 files changed +12
-3
lines changed
2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -26,12 +26,12 @@ def initialize(claims = {})
26
26
@content_type = 'application/jwt'
27
27
self . typ = :JWT
28
28
self . alg = :none
29
+ update claims
29
30
unless claims . nil?
30
31
[ :exp , :nbf , :iat ] . each do |key |
31
- claims [ key ] = claims [ key ] . to_i if claims [ key ]
32
+ self [ key ] = self [ key ] . to_i if self [ key ]
32
33
end
33
34
end
34
- update claims
35
35
end
36
36
37
37
def sign ( private_key_or_secret , algorithm = :autodetect )
@@ -142,4 +142,4 @@ def pretty_generate(jwt_string)
142
142
require 'json/jwk'
143
143
require 'json/jwk/jwkizable'
144
144
require 'json/jwk/set'
145
- require 'json/jwk/set/fetcher'
145
+ require 'json/jwk/set/fetcher'
Original file line number Diff line number Diff line change 23
23
JSON ::JWT ::VERSION . should_not be_blank
24
24
end
25
25
26
+ describe '#initialize' do
27
+ it "doesn't try to modify a frozen hash" do
28
+ claims = { iss : 'joe' , exp : '1300819380' } . freeze
29
+ jwt = JSON ::JWT . new ( claims )
30
+ expect ( jwt [ :exp ] ) . to eql 1300819380
31
+ expect ( claims [ :exp ] ) . to eql '1300819380'
32
+ end
33
+ end
34
+
26
35
context 'when not signed nor encrypted' do
27
36
it do
28
37
jwt . to_s . should == no_signed
You can’t perform that action at this time.
0 commit comments