Class: Sinatra::Jwt::DummyDecoder

Inherits:
Object
  • Object
show all
Defined in:
lib/sinatra/jwt/dummy_decoder.rb

Class Method Summary collapse

Class Method Details

.decode(token, _key = nil, _verify = false, _options = {}) ⇒ Object

rubocop:disable Style/OptionalBooleanParameter



7
8
9
10
11
12
13
14
# File 'lib/sinatra/jwt/dummy_decoder.rb', line 7

def self.decode(token, _key = nil, _verify = false, _options = {})
  raise JwtDummyDecoderError, "DummyDecoder should not be used in production" if ENV["RACK_ENV"] != "development"

  encoded_header, encoded_payload, _signature = token.split(".")
  [JSON.parse(Base64.decode64(encoded_payload)), JSON.parse(Base64.decode64(encoded_header))]
rescue StandardError
  raise JwtDecodingError, "Decoding error"
end