Module: JwtHandlerRuby
- Defined in:
- lib/jwt_handler_ruby.rb,
lib/jwt_handler_ruby/engine.rb,
lib/jwt_handler_ruby/version.rb,
app/jobs/jwt_handler_ruby/application_job.rb,
app/helpers/jwt_handler_ruby/logins_helper.rb,
app/models/jwt_handler_ruby/application_record.rb,
app/helpers/jwt_handler_ruby/application_helper.rb,
app/mailers/jwt_handler_ruby/application_mailer.rb,
app/controllers/jwt_handler_ruby/logins_controller.rb,
app/controllers/jwt_handler_ruby/application_controller.rb
Defined Under Namespace
Modules: ApplicationHelper, LoginsHelper
Classes: ApplicationController, ApplicationJob, ApplicationMailer, ApplicationRecord, Engine, LoginsController
Constant Summary
collapse
- VERSION =
'0.0.5'
Class Method Summary
collapse
Class Method Details
.decode_user(jwt) ⇒ Object
6
7
8
9
|
# 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) ⇒ Boolean
11
12
13
14
15
16
17
18
19
|
# 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
|