Class: MagentaSSO::Response
- Inherits:
-
Object
- Object
- MagentaSSO::Response
- Defined in:
- lib/magentasso.rb
Overview
A Magenta authentication response
Instance Attribute Summary collapse
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
Returns the value of attribute client_secret.
-
#nonce ⇒ Object
Returns the value of attribute nonce.
-
#scope_data ⇒ Object
Returns the value of attribute scope_data.
-
#user_data ⇒ Object
Returns the value of attribute user_data.
Class Method Summary collapse
Instance Method Summary collapse
- #email_address ⇒ Object
- #external_id ⇒ Object
-
#initialize(client_id, client_secret, nonce, user_data, scope_data) ⇒ Response
constructor
A new instance of Response.
- #profile_name ⇒ Object
- #query_params ⇒ Object
- #sign ⇒ Object
Constructor Details
#initialize(client_id, client_secret, nonce, user_data, scope_data) ⇒ Response
Returns a new instance of Response.
93 94 95 96 97 98 99 |
# File 'lib/magentasso.rb', line 93 def initialize(client_id, client_secret, nonce, user_data, scope_data) @client_id = client_id @client_secret = client_secret @nonce = nonce @user_data = user_data @scope_data = scope_data end |
Instance Attribute Details
#client_id ⇒ Object
Returns the value of attribute client_id.
91 92 93 |
# File 'lib/magentasso.rb', line 91 def client_id @client_id end |
#client_secret ⇒ Object
Returns the value of attribute client_secret.
91 92 93 |
# File 'lib/magentasso.rb', line 91 def client_secret @client_secret end |
#nonce ⇒ Object
Returns the value of attribute nonce.
91 92 93 |
# File 'lib/magentasso.rb', line 91 def nonce @nonce end |
#scope_data ⇒ Object
Returns the value of attribute scope_data.
91 92 93 |
# File 'lib/magentasso.rb', line 91 def scope_data @scope_data end |
#user_data ⇒ Object
Returns the value of attribute user_data.
91 92 93 |
# File 'lib/magentasso.rb', line 91 def user_data @user_data end |
Class Method Details
.verify(payload, signature, client_secret) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/magentasso.rb', line 101 def self.verify(payload, signature, client_secret) payload = ::MagentaSSO.verify_and_decode(payload, signature, client_secret) new( payload["client_id"], client_secret, payload["nonce"], payload["user_data"], payload["scope_data"] ) end |
Instance Method Details
#email_address ⇒ Object
137 138 139 |
# File 'lib/magentasso.rb', line 137 def email_address @user_data&.[]("email") end |
#external_id ⇒ Object
133 134 135 |
# File 'lib/magentasso.rb', line 133 def external_id @user_data&.[]("external_id") end |
#profile_name ⇒ Object
141 142 143 144 145 146 147 148 149 150 |
# File 'lib/magentasso.rb', line 141 def profile_name return nil unless @scope_data.key?("profile") return [@scope_data["profile"]["name_combined"], nil] if @scope_data["profile"].key?("name_combined") [ @scope_data["profile"]["name_first"], @scope_data["profile"]["name_last"] ] end |
#query_params ⇒ Object
124 125 126 127 128 129 130 131 |
# File 'lib/magentasso.rb', line 124 def query_params payload, signature = sign { payload: payload, signature: signature } end |
#sign ⇒ Object
113 114 115 116 117 118 119 120 121 122 |
# File 'lib/magentasso.rb', line 113 def sign payload = { client_id: @client_id, nonce: @nonce, user_data: @user_data, scope_data: @scope_data } ::MagentaSSO.encode_and_sign(payload, @client_secret) end |