module JwtHandlerRuby

Constants

VERSION

Public Class Methods

decode_user(jwt) click to toggle source
# File lib/jwt_handler_ruby.rb, line 6
def self.decode_user(jwt)
  pub_key = OpenSSL::PKey::RSA.new(ENV['JWT_PUBLIC_KEY'])
  JWT.decode(jwt, pub_key, true, algorithm: 'RS256')[0]
end
valid_jwt?(jwt) click to toggle source
# File lib/jwt_handler_ruby.rb, line 11
def self.valid_jwt?(jwt)
  pub_key = OpenSSL::PKey::RSA.new(ENV['JWT_PUBLIC_KEY'])
  begin
    JWT.decode(jwt, pub_key, true, algorithm: 'RS256')[0]
  rescue JWT::DecodeError
    return false
  end
  true
end