Module: Henlo::Identifiable

Defined in:
lib/henlo/identifiable.rb

Overview

Generates id token. The id token is used to identify and authenticate the user before responding to a request

Class Method Summary collapse

Class Method Details

.generate_identifiable(options = {}) ⇒ Object

Generates id token and returns both the token, with the optional payload encoded, and the token expiry time in unix seconds



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/henlo/identifiable.rb', line 10

def self.generate_identifiable(options={})
  claim = options || nil 
 
  claim.merge!({
    exp: Time.now.utc.to_i + Henlo.id_token_lifetime, 
    jti: Henlo::Helpers::Util.generate_jti,
    type: "id"
  })

  Hash[
    token: Knock::AuthToken.new(payload: claim).token, 
    exp: claim[:exp]       
  ]
end