zaikio-jwt_auth 2.7.1 → 2.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6aca1e0e80a0c54812e20a453cc9dab23dcee7063a1930912cb80fc2c4f9954
4
- data.tar.gz: 25ea09ed2b55152eaad0b128a6a77e45789726dfa40cb29c486fbca432cd158e
3
+ metadata.gz: f308d2a04e7881d90f571269979d86d58295f6e377ea88db424474a065536e88
4
+ data.tar.gz: 3b08b008750bfc44e32568d1855dfd7a861bbdd2be5da7aaf230299a5f05a77d
5
5
  SHA512:
6
- metadata.gz: 125f688a9367a99cb4c3435e2d847e4d72cf1f293a632371b264a196c055ff7a54faad82e47e92ca3ea186e401bb56704701f9baeb7d9228c3ab511c8c42bde9
7
- data.tar.gz: 3e906f56c06db29e6170ccb166df86196c2dfaa1c798ebc01d58f5f1f575aaa90436ba63a78905fb4007cf92ea6ca74877fb01968c728bcbbcbe29c03ff2a207
6
+ metadata.gz: a75934a43fa21961b000e2ce08d9306877f1a11318738a03ef608aad8006d8356637a51f116b089d7de9c2d9f25f4fcf2bdb3f788401b6bf941008291b55f341
7
+ data.tar.gz: 72c7ac1c7a09da85234c31568943f8ebd6fae9f0c0cdf85f2b16728bec36cde953155e2a1312271e34da5eca17fd9cfe6baeb20b8c2c753387770d5c89822508
@@ -21,8 +21,13 @@ module Zaikio
21
21
  }
22
22
  end
23
23
 
24
- def initialize(payload)
24
+ def initialize(payload, token: nil)
25
25
  @payload = payload
26
+ @token = token
27
+ end
28
+
29
+ def to_s
30
+ @token
26
31
  end
27
32
 
28
33
  def audience
@@ -1,5 +1,5 @@
1
1
  module Zaikio
2
2
  module JWTAuth
3
- VERSION = "2.7.1".freeze
3
+ VERSION = "2.8.1".freeze
4
4
  end
5
5
  end
@@ -62,7 +62,15 @@ module Zaikio
62
62
  HEADER_FORMAT = /\ABearer (.+)\z/.freeze
63
63
 
64
64
  def self.extract(authorization_header_string, **options)
65
- return TokenData.new(Zaikio::JWTAuth.mocked_jwt_payload) if Zaikio::JWTAuth.mocked_jwt_payload
65
+ if Zaikio::JWTAuth.mocked_jwt_payload
66
+ jwk = Zaikio::JWTAuth::TestHelper.jwk
67
+ return TokenData.new(Zaikio::JWTAuth.mocked_jwt_payload, token: JWT.encode(
68
+ Zaikio::JWTAuth.mocked_jwt_payload,
69
+ jwk.signing_key,
70
+ jwk[:alg],
71
+ kid: jwk[:kid]
72
+ ))
73
+ end
66
74
 
67
75
  return if authorization_header_string.blank?
68
76
 
@@ -72,13 +80,13 @@ module Zaikio
72
80
 
73
81
  payload, = JWT.decode(token, nil, true, **options)
74
82
 
75
- TokenData.new(payload)
83
+ TokenData.new(payload, token: token)
76
84
  end
77
85
 
78
86
  def self.decode_jwt(token, **options)
79
87
  options = options.reverse_merge(algorithms: ["RS256"], jwks: JWK.loader)
80
88
  payload, = JWT.decode(token, nil, true, **options)
81
- TokenData.new(payload)
89
+ TokenData.new(payload, token: token)
82
90
  end
83
91
 
84
92
  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.7.1
4
+ version: 2.8.1
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-07-21 00:00:00.000000000 Z
13
+ date: 2023-09-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activejob