json-jwt 1.14.0 → 1.15.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.
Potentially problematic release.
This version of json-jwt might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.github/workflows/test_ruby.yml +30 -0
- data/.travis.yml +3 -4
- data/VERSION +1 -1
- data/bin/console +14 -0
- data/json-jwt.gemspec +2 -0
- data/lib/json/jwk/set/fetcher/debugger/request_filter.rb +34 -0
- data/lib/json/jwk/set/fetcher.rb +83 -0
- data/lib/json/jwt.rb +7 -0
- metadata +39 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 881eaf3476eb9b98f7e02ba780e2893398f79f707c55c7e151f1de8f1a344f5c
|
4
|
+
data.tar.gz: fe2329046f613383e73b4b8579d440f6e394457ad3b090fee27c373b47daa690
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d337b0e27607d55697ae6e162b25674fbcc27b21fe23bfa34d42bc4812e0a35f39f95b8eff66b7a4f6de7e78e883450f6e580931164c632a0146253b7ee89d58
|
7
|
+
data.tar.gz: 0fea890071b4038cbc4ee8080d5c99388035f7642707dd1f4303bcafd7f5f9d8c2f517a5d938d988b551d680211ef6909987b6bbd7e3a5d4688136e37a469f54
|
@@ -0,0 +1,30 @@
|
|
1
|
+
name: Test Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
pull_request:
|
6
|
+
|
7
|
+
permissions:
|
8
|
+
contents: read
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
test:
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
os: ['ubuntu-18.04', 'ubuntu-20.04']
|
15
|
+
ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1']
|
16
|
+
# ubuntu 22.04 only supports ssl 3 and thus only ruby 3.1
|
17
|
+
include:
|
18
|
+
- os: 'ubuntu-22.04'
|
19
|
+
ruby-version: '3.1'
|
20
|
+
runs-on: ${{ matrix.os }}
|
21
|
+
|
22
|
+
steps:
|
23
|
+
- uses: actions/checkout@v3
|
24
|
+
- name: Set up Ruby
|
25
|
+
uses: ruby/setup-ruby@v1
|
26
|
+
with:
|
27
|
+
ruby-version: ${{ matrix.ruby-version }}
|
28
|
+
bundler-cache: true
|
29
|
+
- name: Run tests
|
30
|
+
run: bundle exec rake
|
data/.travis.yml
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.15.0
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "json/jwt"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/json-jwt.gemspec
CHANGED
@@ -16,8 +16,10 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.add_runtime_dependency 'activesupport', '>= 4.2'
|
17
17
|
gem.add_runtime_dependency 'bindata'
|
18
18
|
gem.add_runtime_dependency 'aes_key_wrap'
|
19
|
+
gem.add_runtime_dependency 'httpclient'
|
19
20
|
gem.add_development_dependency 'rake'
|
20
21
|
gem.add_development_dependency 'simplecov'
|
22
|
+
gem.add_development_dependency 'webmock'
|
21
23
|
gem.add_development_dependency 'rspec'
|
22
24
|
gem.add_development_dependency 'rspec-its'
|
23
25
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module JSON
|
2
|
+
class JWK
|
3
|
+
class Set
|
4
|
+
module Fetcher
|
5
|
+
module Debugger
|
6
|
+
class RequestFilter
|
7
|
+
# Callback called in HTTPClient (before sending a request)
|
8
|
+
# request:: HTTP::Message
|
9
|
+
def filter_request(request)
|
10
|
+
started = "======= [JSON::JWK::Set::Fetcher] HTTP REQUEST STARTED ======="
|
11
|
+
log started, request.dump
|
12
|
+
end
|
13
|
+
|
14
|
+
# Callback called in HTTPClient (after received a response)
|
15
|
+
# request:: HTTP::Message
|
16
|
+
# response:: HTTP::Message
|
17
|
+
def filter_response(request, response)
|
18
|
+
finished = "======= [JSON::JWK::Set::Fetcher] HTTP REQUEST FINISHED ======="
|
19
|
+
log '-' * 50, response.dump, finished
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def log(*outputs)
|
25
|
+
outputs.each do |output|
|
26
|
+
JSON::JWK::Set::Fetcher.logger.info output
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module JSON
|
2
|
+
class JWK
|
3
|
+
class Set
|
4
|
+
module Fetcher
|
5
|
+
class Cache
|
6
|
+
def fetch(cache_key)
|
7
|
+
yield
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.logger
|
12
|
+
@@logger
|
13
|
+
end
|
14
|
+
def self.logger=(logger)
|
15
|
+
@@logger = logger
|
16
|
+
end
|
17
|
+
self.logger = Logger.new(STDOUT)
|
18
|
+
self.logger.progname = 'JSON::JWK::Set::Fetcher'
|
19
|
+
|
20
|
+
def self.debugging?
|
21
|
+
@@debugging
|
22
|
+
end
|
23
|
+
def self.debugging=(boolean)
|
24
|
+
@@debugging = boolean
|
25
|
+
end
|
26
|
+
def self.debug!
|
27
|
+
self.debugging = true
|
28
|
+
end
|
29
|
+
def self.debug(&block)
|
30
|
+
original = self.debugging?
|
31
|
+
debug!
|
32
|
+
yield
|
33
|
+
ensure
|
34
|
+
self.debugging = original
|
35
|
+
end
|
36
|
+
self.debugging = false
|
37
|
+
|
38
|
+
def self.http_client
|
39
|
+
_http_client_ = HTTPClient.new(
|
40
|
+
agent_name: "JSON::JWK::Set::Fetcher (#{JSON::JWT::VERSION})"
|
41
|
+
)
|
42
|
+
|
43
|
+
# NOTE: httpclient gem seems stopped maintaining root certtificate set, use OS default.
|
44
|
+
_http_client_.ssl_config.clear_cert_store
|
45
|
+
_http_client_.ssl_config.cert_store.set_default_paths
|
46
|
+
|
47
|
+
_http_client_.request_filter << Debugger::RequestFilter.new if debugging?
|
48
|
+
http_config.try(:call, _http_client_)
|
49
|
+
_http_client_
|
50
|
+
end
|
51
|
+
def self.http_config(&block)
|
52
|
+
@@http_config ||= block
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.cache=(cache)
|
56
|
+
@@cache = cache
|
57
|
+
end
|
58
|
+
def self.cache
|
59
|
+
@@cache
|
60
|
+
end
|
61
|
+
self.cache = Cache.new
|
62
|
+
|
63
|
+
def self.fetch(jwks_uri, kid:)
|
64
|
+
cache_key = [
|
65
|
+
'json:jwk:set',
|
66
|
+
OpenSSL::Digest::MD5.hexdigest(jwks_uri),
|
67
|
+
kid
|
68
|
+
].collect(&:to_s).join(':')
|
69
|
+
jwks = Set.new(
|
70
|
+
JSON.parse(
|
71
|
+
cache.fetch(cache_key) do
|
72
|
+
http_client.get_content(jwks_uri)
|
73
|
+
end
|
74
|
+
)
|
75
|
+
)
|
76
|
+
jwks.detect do |jwk|
|
77
|
+
jwk[:kid] && jwk[:kid] == kid
|
78
|
+
end or raise JWK::Set::KidNotFound
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/json/jwt.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
require 'openssl'
|
2
2
|
require 'base64'
|
3
|
+
require 'httpclient'
|
3
4
|
require 'active_support'
|
4
5
|
require 'active_support/core_ext'
|
5
6
|
require 'json/jose'
|
6
7
|
|
7
8
|
module JSON
|
8
9
|
class JWT < ActiveSupport::HashWithIndifferentAccess
|
10
|
+
VERSION = ::File.read(
|
11
|
+
::File.join(::File.dirname(__FILE__), '../../VERSION')
|
12
|
+
).chomp
|
13
|
+
|
9
14
|
attr_accessor :blank_payload
|
10
15
|
attr_accessor :signature
|
11
16
|
|
@@ -132,3 +137,5 @@ require 'json/jwe'
|
|
132
137
|
require 'json/jwk'
|
133
138
|
require 'json/jwk/jwkizable'
|
134
139
|
require 'json/jwk/set'
|
140
|
+
require 'json/jwk/set/fetcher'
|
141
|
+
require 'json/jwk/set/fetcher/debugger/request_filter'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json-jwt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nov matake
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: httpclient
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rake
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +94,20 @@ dependencies:
|
|
80
94
|
- - ">="
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webmock
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
112
|
name: rspec
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,11 +140,13 @@ description: JSON Web Token and its family (JSON Web Signature, JSON Web Encrypt
|
|
112
140
|
and JSON Web Key) in Ruby
|
113
141
|
email:
|
114
142
|
- nov@matake.jp
|
115
|
-
executables:
|
143
|
+
executables:
|
144
|
+
- console
|
116
145
|
extensions: []
|
117
146
|
extra_rdoc_files: []
|
118
147
|
files:
|
119
148
|
- ".github/FUNDING.yml"
|
149
|
+
- ".github/workflows/test_ruby.yml"
|
120
150
|
- ".gitignore"
|
121
151
|
- ".gitmodules"
|
122
152
|
- ".rspec"
|
@@ -126,19 +156,22 @@ files:
|
|
126
156
|
- README.md
|
127
157
|
- Rakefile
|
128
158
|
- VERSION
|
159
|
+
- bin/console
|
129
160
|
- json-jwt.gemspec
|
130
161
|
- lib/json/jose.rb
|
131
162
|
- lib/json/jwe.rb
|
132
163
|
- lib/json/jwk.rb
|
133
164
|
- lib/json/jwk/jwkizable.rb
|
134
165
|
- lib/json/jwk/set.rb
|
166
|
+
- lib/json/jwk/set/fetcher.rb
|
167
|
+
- lib/json/jwk/set/fetcher/debugger/request_filter.rb
|
135
168
|
- lib/json/jws.rb
|
136
169
|
- lib/json/jwt.rb
|
137
170
|
homepage: https://github.com/nov/json-jwt
|
138
171
|
licenses:
|
139
172
|
- MIT
|
140
173
|
metadata: {}
|
141
|
-
post_install_message:
|
174
|
+
post_install_message:
|
142
175
|
rdoc_options: []
|
143
176
|
require_paths:
|
144
177
|
- lib
|
@@ -154,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
187
|
version: '0'
|
155
188
|
requirements: []
|
156
189
|
rubygems_version: 3.1.6
|
157
|
-
signing_key:
|
190
|
+
signing_key:
|
158
191
|
specification_version: 4
|
159
192
|
summary: JSON Web Token and its family (JSON Web Signature, JSON Web Encryption and
|
160
193
|
JSON Web Key) in Ruby
|