Module: MVPaaS::Auth
- Defined in:
- lib/mvpaas/auth.rb
Class Method Summary collapse
Class Method Details
.decode(token, secret = nil) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/mvpaas/auth.rb', line 10 def decode(token, secret = nil) decoded_secret = Base64.urlsafe_decode64(secret || ENV['MVPAAS_SECRET']).gsub("\\n","\n") rsa_key = OpenSSL::PKey::RSA.new(decoded_secret,'').public_key decoded_jwt = JWT.decode(token, rsa_key, true, algorithm: 'RS256')[0] { id: decoded_jwt['sub'], email: decoded_jwt['username'], } end |