zaikio-jwt_auth 2.7.0 → 2.8.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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c24518cc88a6fd45b415882497799e08ba4e9f8962a59b58e6bf80a0e3a79478
|
4
|
+
data.tar.gz: 04ceb1db55359f0a7a1506efd9df3b20f77de892a11e61fc19f4c28ba3492792
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b89cff570d1274a8b3c06311f67ddd487725ddca9d7cd8d098e5a174b025a1d9f9e811348d2b3dd9c5bd1f0d9bb67999bdd67e85b321dc704c3489412b31ff8
|
7
|
+
data.tar.gz: c1ebdd6aeb037503643b5704bd3682d4d64c62b62fc2d316f9480797069136d1d1e042de1244db714edcd01c2fa69af6ba6cdb31bf18c97a1e8426b25c05846c
|
@@ -11,7 +11,7 @@ module Zaikio
|
|
11
11
|
production: "https://hub.zaikio.com"
|
12
12
|
}.freeze
|
13
13
|
|
14
|
-
attr_accessor :app_name, :cache, :host
|
14
|
+
attr_accessor :app_name, :cache, :host, :test_mode
|
15
15
|
attr_reader :environment
|
16
16
|
attr_writer :logger, :revoked_token_ids, :keys
|
17
17
|
|
@@ -19,6 +19,7 @@ module Zaikio
|
|
19
19
|
@environment = :sandbox
|
20
20
|
@revoked_token_ids = nil
|
21
21
|
@keys = nil
|
22
|
+
@test_mode = false
|
22
23
|
end
|
23
24
|
|
24
25
|
def logger
|
data/lib/zaikio/jwt_auth/jwk.rb
CHANGED
@@ -10,7 +10,10 @@ module Zaikio
|
|
10
10
|
class << self
|
11
11
|
def loader
|
12
12
|
lambda do |options|
|
13
|
+
return TestHelper.jwk_set if JWTAuth.configuration.test_mode
|
14
|
+
|
13
15
|
reload_keys if options[:invalidate]
|
16
|
+
|
14
17
|
{
|
15
18
|
keys: keys.map do |key_data|
|
16
19
|
JWT::JWK.import(key_data.with_indifferent_access).export
|
@@ -1,13 +1,36 @@
|
|
1
1
|
module Zaikio
|
2
2
|
module JWTAuth
|
3
3
|
module TestHelper
|
4
|
+
def self.jwk
|
5
|
+
@jwk ||= JWT::JWK.new(OpenSSL::PKey::RSA.new(2048), { kid: "test-kid", use: "sig", alg: "RS256" })
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.jwk_set
|
9
|
+
@jwk_set ||= JWT::JWK::Set.new(jwk).export
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
|
4
14
|
def after_teardown
|
5
15
|
Zaikio::JWTAuth.mocked_jwt_payload = nil
|
6
16
|
super
|
7
17
|
end
|
8
18
|
|
9
|
-
def mock_jwt(
|
10
|
-
Zaikio::JWTAuth.mocked_jwt_payload =
|
19
|
+
def mock_jwt(params)
|
20
|
+
Zaikio::JWTAuth.mocked_jwt_payload = generate_token_payload(params)
|
21
|
+
end
|
22
|
+
|
23
|
+
def issue_mock_jwt_token(params)
|
24
|
+
JWT.encode(
|
25
|
+
generate_token_payload(params),
|
26
|
+
jwk.signing_key,
|
27
|
+
jwk[:alg],
|
28
|
+
kid: jwk[:kid]
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
def generate_token_payload(params)
|
33
|
+
{
|
11
34
|
iss: "ZAI",
|
12
35
|
sub: nil,
|
13
36
|
aud: %w[test_app],
|
@@ -16,8 +39,10 @@ module Zaikio
|
|
16
39
|
exp: 1.hour.from_now.to_i,
|
17
40
|
jku: "http://hub.zaikio.test/api/v1/jwt_public_keys.json",
|
18
41
|
scope: []
|
19
|
-
}.merge(
|
42
|
+
}.merge(params).stringify_keys
|
20
43
|
end
|
44
|
+
|
45
|
+
def jwk = Zaikio::JWTAuth::TestHelper.jwk
|
21
46
|
end
|
22
47
|
end
|
23
48
|
end
|
data/lib/zaikio/jwt_auth.rb
CHANGED
@@ -72,7 +72,13 @@ module Zaikio
|
|
72
72
|
|
73
73
|
payload, = JWT.decode(token, nil, true, **options)
|
74
74
|
|
75
|
-
TokenData.new(payload)
|
75
|
+
TokenData.new(payload, token: token)
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.decode_jwt(token, **options)
|
79
|
+
options = options.reverse_merge(algorithms: ["RS256"], jwks: JWK.loader)
|
80
|
+
payload, = JWT.decode(token, nil, true, **options)
|
81
|
+
TokenData.new(payload, token: token)
|
76
82
|
end
|
77
83
|
|
78
84
|
module ClassMethods
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zaikio-jwt_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- crispymtn
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-
|
13
|
+
date: 2023-09-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activejob
|
@@ -68,7 +68,7 @@ dependencies:
|
|
68
68
|
- - ">="
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: 2.2.1
|
71
|
-
description: JWT-Based authentication and authorization with
|
71
|
+
description: JWT-Based authentication and authorization with Zaikio.
|
72
72
|
email:
|
73
73
|
- op@crispymtn.com
|
74
74
|
- js@crispymtn.com
|
@@ -117,5 +117,5 @@ requirements: []
|
|
117
117
|
rubygems_version: 3.3.11
|
118
118
|
signing_key:
|
119
119
|
specification_version: 4
|
120
|
-
summary: JWT-Based authentication and authorization with
|
120
|
+
summary: JWT-Based authentication and authorization with Zaikio
|
121
121
|
test_files: []
|