Class: SelfSDK::Messages::AuthenticationReq
- Inherits:
-
AuthenticationMessage
- Object
- Base
- AuthenticationMessage
- SelfSDK::Messages::AuthenticationReq
- Defined in:
- lib/messages/authentication_req.rb
Constant Summary collapse
- MSG_TYPE =
"identities.authenticate.req"
- DEFAULT_EXP_TIMEOUT =
300
Instance Attribute Summary
Attributes inherited from Base
#description, #exp_timeout, #expires, #fields, #from, #from_device, #id, #input, #intermediary, #payload, #status, #sub, #to, #to_device, #typ
Instance Method Summary collapse
- #body ⇒ Object
-
#initialize(messaging) ⇒ AuthenticationReq
constructor
A new instance of AuthenticationReq.
- #populate(selfid, opts) ⇒ Object
Methods inherited from AuthenticationMessage
Methods inherited from Base
#accepted?, #encrypt_message, #errored?, #rejected?, #request, #send_message, #unauthorized?, #validate!
Constructor Details
permalink #initialize(messaging) ⇒ AuthenticationReq
Returns a new instance of AuthenticationReq.
13 14 15 16 |
# File 'lib/messages/authentication_req.rb', line 13 def initialize(messaging) @typ = MSG_TYPE super end |
Instance Method Details
permalink #body ⇒ Object
[View source]
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/messages/authentication_req.rb', line 28 def body { typ: MSG_TYPE, iss: @jwt.id, sub: @to, aud: @to, iat: SelfSDK::Time.now.strftime('%FT%TZ'), exp: (SelfSDK::Time.now + @exp_timeout).strftime('%FT%TZ'), cid: @id, jti: SecureRandom.uuid } end |
permalink #populate(selfid, opts) ⇒ Object
[View source]
18 19 20 21 22 23 24 25 26 |
# File 'lib/messages/authentication_req.rb', line 18 def populate(selfid, opts) @id = SecureRandom.uuid @from = @client.jwt.id @to = selfid @id = opts[:cid] if opts.include?(:cid) @description = opts.include?(:description) ? opts[:description] : nil @exp_timeout = opts.fetch(:exp_timeout, DEFAULT_EXP_TIMEOUT) end |