Module: DecodeThis
- Defined in:
- lib/decode_this.rb,
lib/decode_this/version.rb,
lib/decode_this/safe_decoding.rb
Defined Under Namespace
Classes: SafeDecoding
Constant Summary collapse
- VERSION =
'0.1.7'- BaseError =
Class.new(RuntimeError)
- ConfigFileNotFoundError =
Class.new(BaseError)
- KeyFileNotFoundError =
Class.new(BaseError)
- DecodeError =
Class.new(BaseError)
Class Method Summary collapse
- .config ⇒ Object
- .config_path ⇒ Object
- .config_path=(config_path) ⇒ Object
- .decode(header_value) ⇒ Object
- .env ⇒ Object
- .env=(env) ⇒ Object
- .logger ⇒ Object
- .logger=(logger) ⇒ Object
Class Method Details
.config ⇒ Object
14 15 16 17 18 |
# File 'lib/decode_this.rb', line 14 def self.config raise ConfigFileNotFoundError.new("Cannot found configuration file in #{@config_path}") unless @config_path @config ||= YAML.load(File.open(@config_path))[@env] end |
.config_path ⇒ Object
24 25 26 |
# File 'lib/decode_this.rb', line 24 def self.config_path @config_path end |
.config_path=(config_path) ⇒ Object
20 21 22 |
# File 'lib/decode_this.rb', line 20 def self.config_path=(config_path) @config_path = File.(config_path) end |
.decode(header_value) ⇒ Object
8 9 10 11 12 |
# File 'lib/decode_this.rb', line 8 def self.decode(header_value) token = token_from_header(header_value) safe_decode { JWT.decode(token, public_key, true, algorithm: config['algorithm']).first } end |
.env ⇒ Object
40 41 42 |
# File 'lib/decode_this.rb', line 40 def self.env @env end |
.env=(env) ⇒ Object
36 37 38 |
# File 'lib/decode_this.rb', line 36 def self.env=(env) @env = env.to_s end |
.logger ⇒ Object
28 29 30 |
# File 'lib/decode_this.rb', line 28 def self.logger @logger end |
.logger=(logger) ⇒ Object
32 33 34 |
# File 'lib/decode_this.rb', line 32 def self.logger=(logger) @logger = logger end |