Update rake task file

This commit is contained in:
Xavier J 2016-02-02 10:24:36 +01:00
parent 71adc70031
commit 73ca7560d4

View file

@ -2,40 +2,37 @@ namespace :dev do
desc 'Initialise dev environment' desc 'Initialise dev environment'
task :init do task :init do
puts 'start initialisation' puts 'start initialisation'
Rake::Task['dev:generate_secret_token_file'].invoke Rake::Task['dev:generate_token_file'].invoke
Rake::Task['dev:generate_clients_basic_auth'].invoke Rake::Task['dev:generate_franceconnect_file'].invoke
puts 'end initialisation' puts 'end initialisation'
end end
task :generate_clients_basic_auth do task :generate_token_file do
puts 'creating clients_basic_auth.yml file' puts 'creating token.rb file'
file = File.new('config/clients_basic_auth.yml', 'w+') res = `rake secret`.gsub("\n", '')
credentials = <<EOF file = File.new('config/initializers/token.rb', 'w+')
username: toto comment = <<EOF
password: password
EOF EOF
file.write(credentials) file.write(comment)
file.write("TPS::Application.config.SIADETOKEN = '#{res}'")
file.close file.close
end end
task :generate_secret_token_file do task :generate_franceconnect_file do
puts 'creating secret_token.rb file' file = File.new('config/france_connect.yml', 'w+')
res = `rake secret`.gsub("\n", '')
file = File.new('config/initializers/secret_token.rb', 'w+')
comment = <<EOF comment = <<EOF
# Be sure to restart your server when you modify this file. particulier_identifier: plop
# Your secret key is used for verifying the integrity of signed cookies. particulier_secret: plip
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random, particulier_redirect_uri: 'http://localhost:3000/france_connect/particulier/callback'
# no regular words or you'll be exposed to dictionary attacks.
# You can use `rake secret` to generate a secure secret key.
# Make sure your secret_key_base is kept private particulier_authorization_endpoint: 'https://fcp.integ01.dev-franceconnect.fr/api/v1/authorize'
# if you're sharing your code publicly. particulier_token_endpoint: 'https://fcp.integ01.dev-franceconnect.fr/api/v1/token'
particulier_userinfo_endpoint: 'https://fcp.integ01.dev-franceconnect.fr/api/v1/userinfo'
particulier_logout_endpoint: 'https://fcp.integ01.dev-franceconnect.fr/api/v1/logout'
EOF EOF
file.write(comment) file.write(comment)
file.write("TPS::Application.config.secret_key_base = '#{res}'")
file.close file.close
end end
end end