class Gr1d99Auth::JWT
Attributes
config[R]
Public Class Methods
decode(token)
click to toggle source
# File lib/gr1d99_auth/jwt.rb, line 15 def self.decode(token) new.decode(token) end
encode(payload)
click to toggle source
# File lib/gr1d99_auth/jwt.rb, line 11 def self.encode(payload) new.encode(payload) end
new()
click to toggle source
# File lib/gr1d99_auth/jwt.rb, line 7 def initialize @config = Gr1d99Auth.configuration end
Public Instance Methods
decode(token)
click to toggle source
# File lib/gr1d99_auth/jwt.rb, line 30 def decode(token) key = config.jwt_key verify = config.jwt_verify opts = { algorithm: config.jwt_algorithm } ::JWT.decode(token, key, verify, opts) end
encode(payload)
click to toggle source
# File lib/gr1d99_auth/jwt.rb, line 19 def encode(payload) if config.jwt_exp payload[:exp] = (Time.zone.now + config.jwt_exp.to_i).to_i end key = config.jwt_key algorithm = config.jwt_algorithm ::JWT.encode(payload, key, algorithm) end