json-jwt 1.16.3 → 1.17.1
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/.github/workflows/spec.yml +9 -9
- data/VERSION +1 -1
- data/json-jwt.gemspec +1 -0
- data/lib/json/jwk/set/fetcher.rb +14 -7
- data/lib/json/jwk/set.rb +1 -1
- data/lib/json/jws.rb +3 -1
- data/lib/json/jwt.rb +8 -4
- metadata +17 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 477700420d1f91dfa45a302ecccc12c76548a8a5f281ac709f2b406b76e2abbf
|
|
4
|
+
data.tar.gz: b4e2f42d9fa50ff0902e8e72a3584ebc760d18b82c857e532f390253472d96a7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 66ce8c45f9d3c046a749e2cff596258eec0d63ee842e8033a691efe745d8cd44b4943a8a70700cd1ee8692e4417ad67b658155a1cc7ad0cd0313d142b4751489
|
|
7
|
+
data.tar.gz: 21e4328f6b842ab18293bd735f973131db0a7ed1f308023ef976df3c25c9a4a0d59e6481f561bfa90b7921560eff7b856cc6b6cffc0e89f68ceb26b012847a39
|
data/.github/workflows/spec.yml
CHANGED
|
@@ -3,7 +3,7 @@ name: Spec
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
5
|
branches:
|
|
6
|
-
-
|
|
6
|
+
- main
|
|
7
7
|
pull_request:
|
|
8
8
|
|
|
9
9
|
permissions:
|
|
@@ -11,21 +11,21 @@ permissions:
|
|
|
11
11
|
|
|
12
12
|
jobs:
|
|
13
13
|
spec:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
name: Ruby ${{ matrix.ruby }}
|
|
14
16
|
strategy:
|
|
15
17
|
matrix:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
runs-on: ${{ matrix.os }}
|
|
22
|
-
|
|
18
|
+
ruby:
|
|
19
|
+
- '3.2'
|
|
20
|
+
- '3.3'
|
|
21
|
+
- '3.4'
|
|
22
|
+
- '4.0'
|
|
23
23
|
steps:
|
|
24
24
|
- uses: actions/checkout@v3
|
|
25
25
|
- name: Set up Ruby
|
|
26
26
|
uses: ruby/setup-ruby@v1
|
|
27
27
|
with:
|
|
28
|
-
ruby-version: ${{ matrix.ruby
|
|
28
|
+
ruby-version: ${{ matrix.ruby }}
|
|
29
29
|
bundler-cache: true
|
|
30
30
|
- name: Run Specs
|
|
31
31
|
run: bundle exec rake spec
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.
|
|
1
|
+
1.17.1
|
data/json-jwt.gemspec
CHANGED
|
@@ -14,6 +14,7 @@ Gem::Specification.new do |gem|
|
|
|
14
14
|
gem.require_paths = ['lib']
|
|
15
15
|
gem.required_ruby_version = '>= 2.4'
|
|
16
16
|
gem.add_runtime_dependency 'activesupport', '>= 4.2'
|
|
17
|
+
gem.add_runtime_dependency 'base64'
|
|
17
18
|
gem.add_runtime_dependency 'bindata'
|
|
18
19
|
gem.add_runtime_dependency 'aes_key_wrap'
|
|
19
20
|
gem.add_runtime_dependency 'faraday', '~> 2.0'
|
data/lib/json/jwk/set/fetcher.rb
CHANGED
|
@@ -2,6 +2,8 @@ module JSON
|
|
|
2
2
|
class JWK
|
|
3
3
|
class Set
|
|
4
4
|
module Fetcher
|
|
5
|
+
class UnexpectedFormat < JWT::Exception; end
|
|
6
|
+
|
|
5
7
|
class Cache
|
|
6
8
|
def fetch(cache_key, options = {})
|
|
7
9
|
yield
|
|
@@ -65,13 +67,18 @@ module JSON
|
|
|
65
67
|
kid
|
|
66
68
|
].collect(&:to_s).join(':')
|
|
67
69
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
end
|
|
73
|
-
)
|
|
70
|
+
parsed_jwks = JSON.parse(
|
|
71
|
+
cache.fetch(cache_key, options) do
|
|
72
|
+
http_client.get(jwks_uri).body
|
|
73
|
+
end
|
|
74
74
|
)
|
|
75
|
+
|
|
76
|
+
unless parsed_jwks.is_a?(Hash) && parsed_jwks['keys'].is_a?(Array)
|
|
77
|
+
cache.delete(cache_key, options)
|
|
78
|
+
raise UnexpectedFormat
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
jwks = Set.new(parsed_jwks)
|
|
75
82
|
cache.delete(cache_key, options) if jwks[kid].blank?
|
|
76
83
|
|
|
77
84
|
if auto_detect
|
|
@@ -83,4 +90,4 @@ module JSON
|
|
|
83
90
|
end
|
|
84
91
|
end
|
|
85
92
|
end
|
|
86
|
-
end
|
|
93
|
+
end
|
data/lib/json/jwk/set.rb
CHANGED
data/lib/json/jws.rb
CHANGED
|
@@ -20,6 +20,7 @@ module JSON
|
|
|
20
20
|
|
|
21
21
|
def verify!(public_key_or_secret, algorithms = nil)
|
|
22
22
|
if alg&.to_sym == :none
|
|
23
|
+
raise UnexpectedAlgorithm unless algorithms.blank? || Array(algorithms).include?(:none)
|
|
23
24
|
raise UnexpectedAlgorithm if public_key_or_secret
|
|
24
25
|
signature == '' or raise VerificationFailed
|
|
25
26
|
elsif algorithms.blank? || Array(algorithms).include?(alg&.to_sym)
|
|
@@ -124,7 +125,8 @@ module JSON
|
|
|
124
125
|
public_key_or_secret = with_jwk_support public_key_or_secret
|
|
125
126
|
case
|
|
126
127
|
when hmac?
|
|
127
|
-
|
|
128
|
+
secret = public_key_or_secret
|
|
129
|
+
secure_compare sign(signature_base_string, secret), signature
|
|
128
130
|
when rsa?
|
|
129
131
|
public_key = public_key_or_secret
|
|
130
132
|
public_key.verify digest, signature, signature_base_string
|
data/lib/json/jwt.rb
CHANGED
|
@@ -26,12 +26,12 @@ module JSON
|
|
|
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
|
-
|
|
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)
|
|
@@ -109,7 +109,11 @@ module JSON
|
|
|
109
109
|
when JWS::NUM_OF_SEGMENTS
|
|
110
110
|
JWS.decode_compact_serialized jwt_string, key_or_secret, algorithms, allow_blank_payload
|
|
111
111
|
when JWE::NUM_OF_SEGMENTS
|
|
112
|
-
|
|
112
|
+
if allow_blank_payload
|
|
113
|
+
raise InvalidFormat.new("JWE w/ blank payload is not supported.")
|
|
114
|
+
else
|
|
115
|
+
JWE.decode_compact_serialized jwt_string, key_or_secret, algorithms, encryption_methods
|
|
116
|
+
end
|
|
113
117
|
else
|
|
114
118
|
raise InvalidFormat.new("Invalid JWT Format. JWT should include #{JWS::NUM_OF_SEGMENTS} or #{JWE::NUM_OF_SEGMENTS} segments.")
|
|
115
119
|
end
|
|
@@ -138,4 +142,4 @@ require 'json/jwe'
|
|
|
138
142
|
require 'json/jwk'
|
|
139
143
|
require 'json/jwk/jwkizable'
|
|
140
144
|
require 'json/jwk/set'
|
|
141
|
-
require 'json/jwk/set/fetcher'
|
|
145
|
+
require 'json/jwk/set/fetcher'
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: json-jwt
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.17.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- nov matake
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activesupport
|
|
@@ -24,6 +23,20 @@ dependencies:
|
|
|
24
23
|
- - ">="
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: '4.2'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: base64
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
27
40
|
- !ruby/object:Gem::Dependency
|
|
28
41
|
name: bindata
|
|
29
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -182,7 +195,6 @@ homepage: https://github.com/nov/json-jwt
|
|
|
182
195
|
licenses:
|
|
183
196
|
- MIT
|
|
184
197
|
metadata: {}
|
|
185
|
-
post_install_message:
|
|
186
198
|
rdoc_options: []
|
|
187
199
|
require_paths:
|
|
188
200
|
- lib
|
|
@@ -197,8 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
197
209
|
- !ruby/object:Gem::Version
|
|
198
210
|
version: '0'
|
|
199
211
|
requirements: []
|
|
200
|
-
rubygems_version:
|
|
201
|
-
signing_key:
|
|
212
|
+
rubygems_version: 4.0.10
|
|
202
213
|
specification_version: 4
|
|
203
214
|
summary: JSON Web Token and its family (JSON Web Signature, JSON Web Encryption and
|
|
204
215
|
JSON Web Key) in Ruby
|