json-jwt 1.15.0 → 1.15.3
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 +2 -2
- data/.travis.yml +1 -0
- data/README.md +11 -0
- data/VERSION +1 -1
- data/lib/json/jose.rb +1 -3
- data/lib/json/jwk/set/fetcher.rb +10 -6
- data/lib/json/jwk/set.rb +6 -0
- metadata +6 -8
- data/bin/console +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bc8f7f5b23b61360c4b6a72c253b52beb5f7226ebf441d6a6561729155ea55d
|
4
|
+
data.tar.gz: 7175e7ea9121d74d633bb32ce6f88e2d50ddbc3b0109426c562508e40a119727
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f169ddb8eafd2b66e84c8fd32328793e040477a376ab7dfedef29990d330afa667f5f563bc540a0479b095cc2c16cb38b6bb7a7a6c9842656ea41425e63c87b7
|
7
|
+
data.tar.gz: 53e010725185c4acab07988025b1dd70d7def52f27c285ed502a21f1d8e8ad1eedca780db14378824ff7891fbd852265b06a2256281c5a07d40545487ad9241c
|
@@ -11,8 +11,8 @@ jobs:
|
|
11
11
|
test:
|
12
12
|
strategy:
|
13
13
|
matrix:
|
14
|
-
os: ['ubuntu-
|
15
|
-
ruby-version: ['2.
|
14
|
+
os: ['ubuntu-20.04']
|
15
|
+
ruby-version: ['2.6', '2.7', '3.0', '3.1']
|
16
16
|
# ubuntu 22.04 only supports ssl 3 and thus only ruby 3.1
|
17
17
|
include:
|
18
18
|
- os: 'ubuntu-22.04'
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -49,6 +49,17 @@ input = "jwt_header.jwt_claims.jwt_signature"
|
|
49
49
|
JSON::JWT.decode(input, public_key)
|
50
50
|
```
|
51
51
|
|
52
|
+
If you need to get a JWK from `jwks_uri` of OpenID Connect IdP, you can use `JSON::JWK::Set::Fetcher` to fetch (& optionally cache) it.
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
# JWK Set Fetching & Caching
|
56
|
+
# NOTE: Optionally by setting cache instance, JWKs are cached by kid.
|
57
|
+
JSON::JWK::Set::Fetcher.cache = Rails.cache
|
58
|
+
|
59
|
+
JSON::JWK::Set::Fetcher.fetch(jwks_uri, kid: kid)
|
60
|
+
# => returns JSON::JWK instance or raise JSON::JWK::Set::KidNotFound
|
61
|
+
```
|
62
|
+
|
52
63
|
For more details, read [Documentation Wiki](https://github.com/nov/json-jwt/wiki).
|
53
64
|
|
54
65
|
## Note on Patches/Pull Requests
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.15.
|
1
|
+
1.15.3
|
data/lib/json/jose.rb
CHANGED
data/lib/json/jwk/set/fetcher.rb
CHANGED
@@ -3,7 +3,7 @@ module JSON
|
|
3
3
|
class Set
|
4
4
|
module Fetcher
|
5
5
|
class Cache
|
6
|
-
def fetch(cache_key)
|
6
|
+
def fetch(cache_key, options = {})
|
7
7
|
yield
|
8
8
|
end
|
9
9
|
end
|
@@ -60,22 +60,26 @@ module JSON
|
|
60
60
|
end
|
61
61
|
self.cache = Cache.new
|
62
62
|
|
63
|
-
def self.fetch(jwks_uri, kid:)
|
63
|
+
def self.fetch(jwks_uri, kid:, auto_detect: true, **options)
|
64
64
|
cache_key = [
|
65
65
|
'json:jwk:set',
|
66
66
|
OpenSSL::Digest::MD5.hexdigest(jwks_uri),
|
67
67
|
kid
|
68
68
|
].collect(&:to_s).join(':')
|
69
|
+
|
69
70
|
jwks = Set.new(
|
70
71
|
JSON.parse(
|
71
|
-
cache.fetch(cache_key) do
|
72
|
+
cache.fetch(cache_key, options) do
|
72
73
|
http_client.get_content(jwks_uri)
|
73
74
|
end
|
74
75
|
)
|
75
76
|
)
|
76
|
-
|
77
|
-
|
78
|
-
|
77
|
+
|
78
|
+
if auto_detect
|
79
|
+
jwks[kid] or raise KidNotFound
|
80
|
+
else
|
81
|
+
jwks
|
82
|
+
end
|
79
83
|
end
|
80
84
|
end
|
81
85
|
end
|
data/lib/json/jwk/set.rb
CHANGED
@@ -19,6 +19,12 @@ module JSON
|
|
19
19
|
'application/jwk-set+json'
|
20
20
|
end
|
21
21
|
|
22
|
+
def [](kid)
|
23
|
+
detect do |jwk|
|
24
|
+
jwk[:kid] && jwk[:kid] == kid
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
22
28
|
def as_json(options = {})
|
23
29
|
# NOTE: Array.new wrapper is requied to avoid CircularReferenceError
|
24
30
|
{keys: Array.new(self)}
|
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.15.
|
4
|
+
version: 1.15.3
|
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-08-
|
11
|
+
date: 2022-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -140,8 +140,7 @@ description: JSON Web Token and its family (JSON Web Signature, JSON Web Encrypt
|
|
140
140
|
and JSON Web Key) in Ruby
|
141
141
|
email:
|
142
142
|
- nov@matake.jp
|
143
|
-
executables:
|
144
|
-
- console
|
143
|
+
executables: []
|
145
144
|
extensions: []
|
146
145
|
extra_rdoc_files: []
|
147
146
|
files:
|
@@ -156,7 +155,6 @@ files:
|
|
156
155
|
- README.md
|
157
156
|
- Rakefile
|
158
157
|
- VERSION
|
159
|
-
- bin/console
|
160
158
|
- json-jwt.gemspec
|
161
159
|
- lib/json/jose.rb
|
162
160
|
- lib/json/jwe.rb
|
@@ -171,7 +169,7 @@ homepage: https://github.com/nov/json-jwt
|
|
171
169
|
licenses:
|
172
170
|
- MIT
|
173
171
|
metadata: {}
|
174
|
-
post_install_message:
|
172
|
+
post_install_message:
|
175
173
|
rdoc_options: []
|
176
174
|
require_paths:
|
177
175
|
- lib
|
@@ -187,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
185
|
version: '0'
|
188
186
|
requirements: []
|
189
187
|
rubygems_version: 3.1.6
|
190
|
-
signing_key:
|
188
|
+
signing_key:
|
191
189
|
specification_version: 4
|
192
190
|
summary: JSON Web Token and its family (JSON Web Signature, JSON Web Encryption and
|
193
191
|
JSON Web Key) in Ruby
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
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__)
|