Class: Layer::IdentityToken

Inherits:
Object
  • Object
show all
Defined in:
lib/layer/identity_token.rb,
lib/layer/identity_token/version.rb

Constant Summary collapse

VERSION =
"0.0.1"

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_id, nonce, expires_at = (Time.now+(86400*14))) ⇒ IdentityToken

Returns a new instance of IdentityToken.



29
30
31
32
33
# File 'lib/layer/identity_token.rb', line 29

def initialize(user_id, nonce, expires_at = (Time.now+(86400*14)))
  @user_id = user_id
  @nonce = nonce
  @expires_at = expires_at
end

Class Attribute Details

.layer_key_idObject



16
17
18
# File 'lib/layer/identity_token.rb', line 16

def layer_key_id
  @layer_key_id || ENV["LAYER_KEY_ID"]
end

.layer_private_keyObject



20
21
22
# File 'lib/layer/identity_token.rb', line 20

def layer_private_key
  @layer_private_key || ENV["LAYER_PRIVATE_KEY"]
end

.layer_provider_idObject



12
13
14
# File 'lib/layer/identity_token.rb', line 12

def layer_provider_id
  @layer_provider_id || ENV["LAYER_PROVIDER_ID"]
end

Instance Attribute Details

#expires_atObject (readonly)

Returns the value of attribute expires_at.



25
26
27
# File 'lib/layer/identity_token.rb', line 25

def expires_at
  @expires_at
end

#nonceObject (readonly)

Returns the value of attribute nonce.



25
26
27
# File 'lib/layer/identity_token.rb', line 25

def nonce
  @nonce
end

#user_idObject (readonly)

Returns the value of attribute user_id.



25
26
27
# File 'lib/layer/identity_token.rb', line 25

def user_id
  @user_id
end

Instance Method Details

#as_json(options = {}) ⇒ Object



39
40
41
# File 'lib/layer/identity_token.rb', line 39

def as_json(options = {})
  encode
end

#encodeObject Also known as: to_s



35
36
37
# File 'lib/layer/identity_token.rb', line 35

def encode
  JWT.encode(claim, private_key, "RS256", headers)
end