Class: Zaikio::Hub::TokenData
- Inherits:
-
Object
- Object
- Zaikio::Hub::TokenData
- Defined in:
- lib/zaikio/hub/token_data.rb
Instance Attribute Summary collapse
-
#audience ⇒ Object
readonly
Returns the value of attribute audience.
-
#on_behalf_of ⇒ Object
readonly
Returns the value of attribute on_behalf_of.
-
#scopes ⇒ Object
readonly
Returns the value of attribute scopes.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(audience:, on_behalf_of:, subject:, scopes:) ⇒ TokenData
constructor
A new instance of TokenData.
- #on_behalf_of_id ⇒ Object
- #on_behalf_of_type ⇒ Object
- #subject_id ⇒ Object
- #subject_type ⇒ Object
Constructor Details
#initialize(audience:, on_behalf_of:, subject:, scopes:) ⇒ TokenData
Returns a new instance of TokenData.
17 18 19 20 21 22 |
# File 'lib/zaikio/hub/token_data.rb', line 17 def initialize(audience:, on_behalf_of:, subject:, scopes:) @audience = audience @on_behalf_of = on_behalf_of @subject = subject @scopes = scopes end |
Instance Attribute Details
#audience ⇒ Object (readonly)
Returns the value of attribute audience.
4 5 6 |
# File 'lib/zaikio/hub/token_data.rb', line 4 def audience @audience end |
#on_behalf_of ⇒ Object (readonly)
Returns the value of attribute on_behalf_of.
4 5 6 |
# File 'lib/zaikio/hub/token_data.rb', line 4 def on_behalf_of @on_behalf_of end |
#scopes ⇒ Object (readonly)
Returns the value of attribute scopes.
4 5 6 |
# File 'lib/zaikio/hub/token_data.rb', line 4 def scopes @scopes end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
4 5 6 |
# File 'lib/zaikio/hub/token_data.rb', line 4 def subject @subject end |
Class Method Details
.from(payload) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/zaikio/hub/token_data.rb', line 6 def self.from(payload) subjects = payload["sub"].split(">") new( audience: payload["aud"].first, on_behalf_of: subjects.first, subject: subjects.last, scopes: payload["scope"] ) end |
Instance Method Details
#on_behalf_of_id ⇒ Object
28 29 30 |
# File 'lib/zaikio/hub/token_data.rb', line 28 def on_behalf_of_id @on_behalf_of_id ||= id_for(:on_behalf_of) end |
#on_behalf_of_type ⇒ Object
24 25 26 |
# File 'lib/zaikio/hub/token_data.rb', line 24 def on_behalf_of_type @on_behalf_of_type ||= type_for(:on_behalf_of) end |
#subject_id ⇒ Object
36 37 38 |
# File 'lib/zaikio/hub/token_data.rb', line 36 def subject_id @subject_id ||= id_for(:subject) end |
#subject_type ⇒ Object
32 33 34 |
# File 'lib/zaikio/hub/token_data.rb', line 32 def subject_type @subject_type ||= type_for(:subject) end |