zaikio-hub 0.10.0 → 0.11.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: e6de6ed1ed5cb7442b72ffa036df6de0cf7f371d59d52018b4458850b7e71848
4
- data.tar.gz: 5dc770e601267c847094fdb07875651529ec14458676c5d5be558af9c0d15c39
3
+ metadata.gz: bc8cad3e052fb8b2a20e218a59ecbaafb01811adc2b166cc512797f9c7d36047
4
+ data.tar.gz: ff4b1176481847d8cc8dd015d6275d2630ff85886d441d8906be591590ec27fa
5
5
  SHA512:
6
- metadata.gz: 2b168642b4f8c6ac5607602a7e2237224e98fe52b4991c3f06b3a61591eeeacb6a6d76a60f63acaa272fe55cb9ee43f42f0a7aea871a3eeca7a2a770abc5f8ae
7
- data.tar.gz: 4aca04231bccaf9dc4d85ebf752ef4663f365cc7bc788a8b55d979983047e4eb78e3978bf2bd28ef274186f7408ce2d5288941b08e4bdb40329ed6468ab000dc
6
+ metadata.gz: 1b05da9a0bf4d590c5fdf7ffd535c3f0d27baaa3cde3d2a4764a4ef5cdd8f8a5414fa5777ac33a3908893096492aa880e1eac9e0a34d6b68eb5fe0115f441214
7
+ data.tar.gz: 7e6ab83a077728d97fb54800aa13bff979a7895fa24b0960d62c14ea4cb36363ac7393be3ff7428548a14c19154116327820b129617ad04a1da224fefc867383
data/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.11.0] - 2022-08-30
11
+
12
+ * Extract token data logic into its own `Zaikio::Hub::TokenData` class
13
+ This also exposes the `sub` attribute of the token as `TokenData#subject`.
14
+ * Support newer versions of `jwt` and `spyke`
15
+
10
16
  ## [0.10.0] - 2022-08-15
11
17
 
12
18
  * Update `zaikio-client-helpers` and reuse logic to use `Zaikio::Client.with_token`
@@ -90,7 +96,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
90
96
  ### Added
91
97
  - Added subscriptions (migration required)
92
98
 
93
- [Unreleased]: https://github.com/zaikio/zaikio-hub-ruby/compare/v0.9.0..HEAD
99
+ [Unreleased]: https://github.com/zaikio/zaikio-hub-ruby/compare/v0.11.0..HEAD
100
+ [0.11.0]: https://github.com/zaikio/zaikio-hub-ruby/compare/v0.10.0..v0.11.0
101
+ [0.10.0]: https://github.com/zaikio/zaikio-hub-ruby/compare/v0.9.0..v0.10.0
94
102
  [0.9.0]: https://github.com/zaikio/zaikio-hub-ruby/compare/v0.8.0..v0.9.0
95
103
  [0.8.0]: https://github.com/zaikio/zaikio-hub-ruby/compare/v0.7.0..v0.8.0
96
104
  [0.7.0]: https://github.com/zaikio/zaikio-hub-ruby/compare/v0.6.2..v0.7.0
@@ -0,0 +1,51 @@
1
+ module Zaikio
2
+ module Hub
3
+ class TokenData
4
+ attr_reader :audience, :on_behalf_of, :subject, :scopes
5
+
6
+ def self.from(payload)
7
+ subjects = payload["sub"].split(">")
8
+
9
+ new(
10
+ audience: payload["aud"].first,
11
+ on_behalf_of: subjects.first,
12
+ subject: subjects.last,
13
+ scopes: payload["scope"]
14
+ )
15
+ end
16
+
17
+ def initialize(audience:, on_behalf_of:, subject:, scopes:)
18
+ @audience = audience
19
+ @on_behalf_of = on_behalf_of
20
+ @subject = subject
21
+ @scopes = scopes
22
+ end
23
+
24
+ def on_behalf_of_type
25
+ @on_behalf_of_type ||= type_for(:on_behalf_of)
26
+ end
27
+
28
+ def on_behalf_of_id
29
+ @on_behalf_of_id ||= id_for(:on_behalf_of)
30
+ end
31
+
32
+ def subject_type
33
+ @subject_type ||= type_for(:subject)
34
+ end
35
+
36
+ def subject_id
37
+ @subject_id ||= id_for(:subject)
38
+ end
39
+
40
+ private
41
+
42
+ def type_for(key)
43
+ public_send(key).split("/").first
44
+ end
45
+
46
+ def id_for(key)
47
+ public_send(key).split("/").last
48
+ end
49
+ end
50
+ end
51
+ end
@@ -1,5 +1,5 @@
1
1
  module Zaikio
2
2
  module Hub
3
- VERSION = "0.10.0".freeze
3
+ VERSION = "0.11.0".freeze
4
4
  end
5
5
  end
data/lib/zaikio/hub.rb CHANGED
@@ -27,6 +27,7 @@ require "zaikio/hub/connection"
27
27
  require "zaikio/hub/app"
28
28
  require "zaikio/hub/subscription"
29
29
  require "zaikio/hub/test_account"
30
+ require "zaikio/hub/token_data"
30
31
 
31
32
  module Zaikio
32
33
  module Hub
@@ -73,15 +74,7 @@ module Zaikio
73
74
  end
74
75
 
75
76
  def create_token_data(payload)
76
- subjects = payload["sub"].split(">")
77
-
78
- OpenStruct.new(
79
- audience: payload["aud"].first,
80
- on_behalf_of_id: subjects.first.split("/").last,
81
- subject_id: subjects.last.split("/").last,
82
- subject_type: subjects.last.split("/").first,
83
- scopes: payload["scope"]
84
- )
77
+ TokenData.from(payload)
85
78
  end
86
79
  end
87
80
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zaikio-hub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.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: 2022-08-15 00:00:00.000000000 Z
13
+ date: 2022-08-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: concurrent-ruby
@@ -35,7 +35,7 @@ dependencies:
35
35
  version: 2.2.1
36
36
  - - "<"
37
37
  - !ruby/object:Gem::Version
38
- version: 2.5.0
38
+ version: 2.6.0
39
39
  type: :runtime
40
40
  prerelease: false
41
41
  version_requirements: !ruby/object:Gem::Requirement
@@ -45,7 +45,7 @@ dependencies:
45
45
  version: 2.2.1
46
46
  - - "<"
47
47
  - !ruby/object:Gem::Version
48
- version: 2.5.0
48
+ version: 2.6.0
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: multi_json
51
51
  requirement: !ruby/object:Gem::Requirement
@@ -157,6 +157,7 @@ files:
157
157
  - lib/zaikio/hub/specialist.rb
158
158
  - lib/zaikio/hub/subscription.rb
159
159
  - lib/zaikio/hub/test_account.rb
160
+ - lib/zaikio/hub/token_data.rb
160
161
  - lib/zaikio/hub/version.rb
161
162
  homepage: https://www.zaikio.com/
162
163
  licenses: