[ENV] Signing key config

# Conflicts:
#	config/secrets.yml
This commit is contained in:
Paul Chavard 2018-08-22 17:08:18 +02:00
parent c79827d551
commit 14f4b16fa4
3 changed files with 4 additions and 13 deletions

View file

@ -1,6 +1,4 @@
class SignatureService
CONFIG_PATH = Rails.root.join("config", "signing_key.yml")
class << self
def generate
RbNaCl::Util.bin2hex(RbNaCl::SigningKey.generate)
@ -24,15 +22,7 @@ class SignatureService
private
def signing_key
@@signing_key ||= RbNaCl::SigningKey.new(RbNaCl::Util.hex2bin(config[:key]))
end
def config
if File.exist?(CONFIG_PATH)
YAML.safe_load(File.read(CONFIG_PATH)).symbolize_keys
else
{}
end
@@signing_key ||= RbNaCl::SigningKey.new(RbNaCl::Util.hex2bin(Rails.application.secrets.signing_key))
end
end
end

View file

@ -11,6 +11,7 @@
# if you're sharing your code publicly.
defaults: &defaults
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
signing_key: <%= ENV["SIGNING_KEY"] %>
basic_auth:
username: <%= ENV['BASIC_AUTH_USERNAME'] %>
password: <%= ENV['BASIC_AUTH_PASSWORD'] %>
@ -46,10 +47,12 @@ defaults: &defaults
development:
<<: *defaults
secret_key_base: 05a2d479d8e412198dabd08ef0eee9d6e180f5cbb48661a35fd1cae287f0a93d40b5f1da08f06780d698bbd458a0ea97f730f83ee780de5d4e31f649a0130cf0
signing_key: aef3153a9829fa4ba10acb02927ac855df6b92795b1ad265d654443c4b14a017
test:
<<: *defaults
secret_key_base: aa52abc3f3a629d04a61e9899a24c12f52b24c679cbf45f8ec0cdcc64ab9526d673adca84212882dff3911ac98e0c32ec4729ca7b3429ba18ef4dfd1bd18bc7a
signing_key: aef3153a9829fa4ba10acb02927ac855df6b92795b1ad265d654443c4b14a017
api_entreprise:
key: api_entreprise_test_key
base_url: https://entreprise.api.gouv.fr/v2

View file

@ -1,2 +0,0 @@
# This is a signing key used in dev and test environments
key: 'aef3153a9829fa4ba10acb02927ac855df6b92795b1ad265d654443c4b14a017'