Class: MagentaSSO::Request
- Inherits:
-
Object
- Object
- MagentaSSO::Request
- Defined in:
- lib/magentasso.rb
Overview
A Magenta authentication request.
Instance Attribute Summary collapse
-
#callback_url ⇒ Object
Returns the value of attribute callback_url.
-
#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.
-
#scopes ⇒ Object
Returns the value of attribute scopes.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(client_id, client_secret, nonce, scopes, callback_url) ⇒ Request
constructor
A new instance of Request.
- #query_params ⇒ Object
- #sign ⇒ Object
Constructor Details
#initialize(client_id, client_secret, nonce, scopes, callback_url) ⇒ Request
Returns a new instance of Request.
47 48 49 50 51 52 53 |
# File 'lib/magentasso.rb', line 47 def initialize(client_id, client_secret, nonce, scopes, callback_url) @client_id = client_id @client_secret = client_secret @nonce = nonce || SecureRandom.random_number(9_999_999) @scopes = [scopes].flatten @callback_url = callback_url end |
Instance Attribute Details
#callback_url ⇒ Object
Returns the value of attribute callback_url.
45 46 47 |
# File 'lib/magentasso.rb', line 45 def callback_url @callback_url end |
#client_id ⇒ Object
Returns the value of attribute client_id.
45 46 47 |
# File 'lib/magentasso.rb', line 45 def client_id @client_id end |
#client_secret ⇒ Object
Returns the value of attribute client_secret.
45 46 47 |
# File 'lib/magentasso.rb', line 45 def client_secret @client_secret end |
#nonce ⇒ Object
Returns the value of attribute nonce.
45 46 47 |
# File 'lib/magentasso.rb', line 45 def nonce @nonce end |
#scopes ⇒ Object
Returns the value of attribute scopes.
45 46 47 |
# File 'lib/magentasso.rb', line 45 def scopes @scopes end |
Class Method Details
.verify(payload, signature, client_secret) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/magentasso.rb', line 55 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["scopes"], payload["callback_url"] ) end |
Instance Method Details
#query_params ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/magentasso.rb', line 78 def query_params payload, signature = sign { client: @client_id, payload: payload, signature: signature } end |
#sign ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/magentasso.rb', line 67 def sign payload = { client_id: @client_id, nonce: @nonce, scopes: @scopes, callback_url: @callback_url } ::MagentaSSO.encode_and_sign(payload, @client_secret) end |