Configure OSEM via environment variables

Instead of reading a yaml file we get configuration from the
environment.
This commit is contained in:
Henne Vogelsang 2016-03-22 18:14:40 +01:00
parent 45c31f210f
commit ebcb2780cd
17 changed files with 39 additions and 34 deletions

View file

@ -35,7 +35,10 @@ Osem::Application.configure do
config.eager_load = false
# Set the detault url for action mailer
config.action_mailer.default_url_options = { host: CONFIG['url_for_emails'] }
config.action_mailer.default_url_options = { host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000') }
# Set the secret key base if it's not set via other means
config.secret_key_base ||= 'f4be765bc98e516de82ac01daa8f8aa11c5ca13cb6c911887851ac89457b6c0b056b2361a21b5c08926c9386e0f91eef84fc0b103d522bf00bc0c78ea8ce7c58'
# Use omniauth mock credentials
OmniAuth.config.test_mode = true

View file

@ -67,7 +67,7 @@ Osem::Application.configure do
config.active_support.deprecation = :notify
# Set the detault url for action mailer
config.action_mailer.default_url_options = { host: CONFIG['url_for_emails'] }
config.action_mailer.default_url_options = { host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000') }
# Set the smtp configuration of your service provider
# For further details of each configuration checkout: http://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration
@ -78,4 +78,7 @@ Osem::Application.configure do
password: CONFIG['MAIL_PASSWORD'],
authentication: CONFIG['MAIL_AUTHENTICATION']
}
# Set the secret_key_base from the env, if not set by any other means
config.secret_key_base ||= ENV["SECRET_KEY_BASE"]
end

View file

@ -2,24 +2,21 @@
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
# ==> Secret key, generate one with `rake secret`
config.secret_key = Rails.application.secrets.devise_secret_key
# ==> openIDs configuration
# Define the available openID providers that can be used to log in
# Pass each provider to User model in :omniauth_providers (for open_id providers use their name)
config.omniauth :open_id, name: 'suse', identifier: 'http://www.opensuse.org/openid/user'
config.omniauth :google_oauth2, Rails.application.secrets.google_key, Rails.application.secrets.google_secret,
config.omniauth :google_oauth2, (ENV['OSEM_GOOGLE_KEY'] || Rails.application.secrets.google_key), (ENV['OSEM_GOOGLE_SECRET'] || Rails.application.secrets.google_secret),
name: 'google',
scope: 'email'
config.omniauth :facebook, Rails.application.secrets.facebook_key, Rails.application.secrets.facebook_secret
config.omniauth :github, Rails.application.secrets.github_key, Rails.application.secrets.github_secret
config.omniauth :facebook, (ENV['OSEM_FACEBOOK_KEY'] || Rails.application.secrets.facebook_key), (ENV['OSEM_FACEBOOK_SECRET'] || Rails.application.secrets.facebook_secret)
config.omniauth :github, (ENV['OSEM_GITHUB_KEY'] || Rails.application.secrets.github_key), (ENV['OSEM_GITHUB_SECRET'] || Rails.application.secrets.github_secret)
# ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class with default "from" parameter.
config.mailer_sender = CONFIG['sender_for_emails']
config.mailer_sender = ENV['OSEM_EMAIL_ADDRESS'] || 'no-reply@localhost'
# Configure the class responsible to send e-mails.
# config.mailer = "Devise::Mailer"

View file

@ -1,7 +1,7 @@
HoptoadNotifier.configure do |config|
# Change this to some sensible data for your errbit instance
config.api_key = Rails.application.secrets.errbit_key || ''
config.host = Rails.application.secrets.errbit_host || ''
config.api_key = ENV['OSEM_ERRBIT_APIKEY'] || Rails.application.secrets.errbit_key || ''
config.host = ENV['OSEM_ERRBIT_HOST']
if config.api_key.blank? || config.host.blank?
config.development_environments = 'production development test'
else

View file

@ -1,6 +1,6 @@
Osem::Application.routes.draw do
if CONFIG['authentication']['ichain']['enabled']
if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
devise_for :users, controllers: { registrations: :registrations }
else
devise_for :users,