class Milkbottle::JwtToken
Attributes
audience[RW]
email[RW]
external_auth_issuer[RW]
external_id[RW]
Public Class Methods
new(options)
click to toggle source
# File lib/milkbottle/jwt_token.rb, line 4 def initialize(options) self.audience = options[:audience] self.email = options[:email] self.external_id = options[:external_id] self.external_auth_issuer = options[:external_auth_issuer] end
Public Instance Methods
encode(external_auth_key)
click to toggle source
# File lib/milkbottle/jwt_token.rb, line 15 def encode(external_auth_key) regenerate if expired? JWT.encode(to_hash, external_auth_key) end
expired?()
click to toggle source
# File lib/milkbottle/jwt_token.rb, line 24 def expired? expiry < Time.now end
expiry()
click to toggle source
# File lib/milkbottle/jwt_token.rb, line 20 def expiry @expiry ||= (Time.now + 3600 * 24) end
issuer()
click to toggle source
# File lib/milkbottle/jwt_token.rb, line 32 def issuer external_auth_issuer end
regenerate()
click to toggle source
# File lib/milkbottle/jwt_token.rb, line 36 def regenerate @expiry = nil end
subject()
click to toggle source
# File lib/milkbottle/jwt_token.rb, line 28 def subject external_id end
to_hash()
click to toggle source
# File lib/milkbottle/jwt_token.rb, line 11 def to_hash { iss: external_auth_issuer, aud: audience, exp: expiry.to_i, sub: subject.to_s, email: email } end