class Lux::Config::Secrets
Attributes
read_file[R]
secret[R]
secret_file[R]
strength[R]
Public Class Methods
new()
click to toggle source
# File lib/lux/config/lib/secrets.rb, line 14 def initialize @read_file = Pathname.new './tmp/secrets.yaml' @secret_file = Pathname.new './config/secrets.enc' @common_file = Pathname.new './config/secrets.yaml' @secret = Lux.config.secret_key_base || Lux.config.secret || ENV['SECRET'] || die('ENV SECRET not found') @strength = 'HS512' end
Public Instance Methods
encoded_data()
click to toggle source
# File lib/lux/config/lib/secrets.rb, line 27 def encoded_data JWT.decode(@secret_file.read, @secret, true, { algorithm: @strength }).first end
load()
click to toggle source
# File lib/lux/config/lib/secrets.rb, line 44 def load to_h.to_readonly end
to_h()
click to toggle source
# File lib/lux/config/lib/secrets.rb, line 31 def to_h it = if @common_file.exist? @common_file.read else encoded_data end it = YAML.load it data = it['shared'] || {} data.merge(it[Lux.env] || {}) end
write()
click to toggle source
# File lib/lux/config/lib/secrets.rb, line 22 def write encoded = JWT.encode @read_file.read, @secret, @strength @secret_file.write encoded end