class Layer::IdentityToken
Constants
- SUPPORTED_CLAIM_ATTRIBUTES
- VERSION
Attributes
layer_key_id[W]
layer_private_key[W]
layer_provider_id[W]
expires_at[R]
more_claim_attributes[R]
nonce[R]
user_id[R]
Public Class Methods
layer_key_id()
click to toggle source
# File lib/layer/identity_token.rb, line 14 def layer_key_id @layer_key_id || ENV["LAYER_KEY_ID"] end
layer_private_key()
click to toggle source
# File lib/layer/identity_token.rb, line 18 def layer_private_key @layer_private_key || ENV["LAYER_PRIVATE_KEY"] end
layer_provider_id()
click to toggle source
# File lib/layer/identity_token.rb, line 10 def layer_provider_id @layer_provider_id || ENV["LAYER_PROVIDER_ID"] end
new(user_id, nonce, expires_at = (Time.now+(86400*14)), more_claim_attributes = {})
click to toggle source
# File lib/layer/identity_token.rb, line 30 def initialize(user_id, nonce, expires_at = (Time.now+(86400*14)), more_claim_attributes = {}) @user_id = user_id @nonce = nonce @expires_at = expires_at @more_claim_attributes = more_claim_attributes.select do |key, _value| SUPPORTED_CLAIM_ATTRIBUTES.include?(key.to_s) end end
Public Instance Methods
as_json(options = {})
click to toggle source
# File lib/layer/identity_token.rb, line 44 def as_json(options = {}) encode end
encode()
click to toggle source
# File lib/layer/identity_token.rb, line 40 def encode JWT.encode(claim, private_key, "RS256", headers) end
Also aliased as: to_s
Private Instance Methods
claim()
click to toggle source
# File lib/layer/identity_token.rb, line 61 def claim more_claim_attributes.merge( iss: self.class.layer_provider_id, prn: user_id.to_s, iat: Time.now.to_i, exp: expires_at.to_i, nce: nonce ) end
headers()
click to toggle source
# File lib/layer/identity_token.rb, line 53 def headers { typ: "JWT", cty: "layer-eit;v=1", kid: self.class.layer_key_id } end
private_key()
click to toggle source
# File lib/layer/identity_token.rb, line 71 def private_key OpenSSL::PKey::RSA.new(self.class.layer_private_key) end