Configure OSEM via environment variables
Instead of reading a yaml file we get configuration from the environment.
This commit is contained in:
parent
45c31f210f
commit
ebcb2780cd
17 changed files with 39 additions and 34 deletions
|
|
@ -13,7 +13,7 @@ class ConferenceRegistrationsController < ApplicationController
|
||||||
redirect_to edit_conference_conference_registrations_path(@conference.short_title)
|
redirect_to edit_conference_conference_registrations_path(@conference.short_title)
|
||||||
return
|
return
|
||||||
# ichain does not allow us to create users during registration
|
# ichain does not allow us to create users during registration
|
||||||
elsif CONFIG['authentication']['ichain']['enabled'] && !current_user
|
elsif (ENV['OSEM_ICHAIN_ENABLED'] == 'true') && !current_user
|
||||||
redirect_to root_path, alert: 'You need to sign in or sign up before continuing.'
|
redirect_to root_path, alert: 'You need to sign in or sign up before continuing.'
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -274,8 +274,10 @@ module ApplicationHelper
|
||||||
unless Rails.application.secrets.send(provider_key).blank? || Rails.application.secrets.send(provider_secret).blank?
|
unless Rails.application.secrets.send(provider_key).blank? || Rails.application.secrets.send(provider_secret).blank?
|
||||||
providers << provider
|
providers << provider
|
||||||
end
|
end
|
||||||
|
providers << provider if !ENV["OSEM_#{provider.upcase}_KEY"].blank? && !ENV["OSEM_#{provider.upcase}_SECRET"].blank?
|
||||||
end
|
end
|
||||||
return providers
|
|
||||||
|
return providers.uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
# Receives a hash, generated from User model, function get_roles
|
# Receives a hash, generated from User model, function get_roles
|
||||||
|
|
@ -294,7 +296,7 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def sign_in_path
|
def sign_in_path
|
||||||
if CONFIG['authentication']['ichain']['enabled']
|
if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
|
||||||
new_user_ichain_session_path
|
new_user_ichain_session_path
|
||||||
else
|
else
|
||||||
new_user_session_path
|
new_user_session_path
|
||||||
|
|
@ -302,7 +304,7 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def sign_up_path
|
def sign_up_path
|
||||||
if CONFIG['authentication']['ichain']['enabled']
|
if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
|
||||||
new_user_ichain_registration_path
|
new_user_ichain_registration_path
|
||||||
else
|
else
|
||||||
new_user_registration_path
|
new_user_registration_path
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ class Ability
|
||||||
# can view Commercials of confirmed Events
|
# can view Commercials of confirmed Events
|
||||||
can :show, Commercial, commercialable_type: 'Event', commercialable_id: Event.where(state: 'confirmed').pluck(:id)
|
can :show, Commercial, commercialable_type: 'Event', commercialable_id: Event.where(state: 'confirmed').pluck(:id)
|
||||||
can [:show, :create], User
|
can [:show, :create], User
|
||||||
unless CONFIG['authentication']['ichain']['enabled']
|
unless ENV['OSEM_ICHAIN_ENABLED'] == 'true'
|
||||||
can :show, Registration do |registration|
|
can :show, Registration do |registration|
|
||||||
registration.new_record?
|
registration.new_record?
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,12 @@ class EmailSettings < ActiveRecord::Base
|
||||||
'conference_start_date' => conference.start_date,
|
'conference_start_date' => conference.start_date,
|
||||||
'conference_end_date' => conference.end_date,
|
'conference_end_date' => conference.end_date,
|
||||||
'registrationlink' => Rails.application.routes.url_helpers.conference_conference_registrations_url(
|
'registrationlink' => Rails.application.routes.url_helpers.conference_conference_registrations_url(
|
||||||
conference.short_title, host: CONFIG['url_for_emails']),
|
conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')),
|
||||||
'conference_splash_link' => Rails.application.routes.url_helpers.conference_url(
|
'conference_splash_link' => Rails.application.routes.url_helpers.conference_url(
|
||||||
conference.short_title, host: CONFIG['url_for_emails']),
|
conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')),
|
||||||
|
|
||||||
'schedule_link' => Rails.application.routes.url_helpers.schedule_conference_url(
|
'schedule_link' => Rails.application.routes.url_helpers.schedule_conference_url(
|
||||||
conference.short_title, host: CONFIG['url_for_emails'])
|
conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000'))
|
||||||
}
|
}
|
||||||
|
|
||||||
if conference.program.cfp
|
if conference.program.cfp
|
||||||
|
|
@ -41,7 +41,7 @@ class EmailSettings < ActiveRecord::Base
|
||||||
if event
|
if event
|
||||||
h['eventtitle'] = event.title
|
h['eventtitle'] = event.title
|
||||||
h['proposalslink'] = Rails.application.routes.url_helpers.conference_program_proposal_index_url(
|
h['proposalslink'] = Rails.application.routes.url_helpers.conference_program_proposal_index_url(
|
||||||
conference.short_title, host: CONFIG['url_for_emails'])
|
conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000'))
|
||||||
end
|
end
|
||||||
h
|
h
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ class User < ActiveRecord::Base
|
||||||
# :lockable, :timeoutable and :omniauthable
|
# :lockable, :timeoutable and :omniauthable
|
||||||
devise_modules = []
|
devise_modules = []
|
||||||
|
|
||||||
if CONFIG['authentication']['ichain']['enabled']
|
if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
|
||||||
devise_modules += [ :ichain_authenticatable, :ichain_registerable, :omniauthable, omniauth_providers: [] ]
|
devise_modules += [ :ichain_authenticatable, :ichain_registerable, :omniauthable, omniauth_providers: [] ]
|
||||||
else
|
else
|
||||||
devise_modules += [:database_authenticatable, :registerable,
|
devise_modules += [:database_authenticatable, :registerable,
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
%legend
|
%legend
|
||||||
%span
|
%span
|
||||||
=link_to('#signup', role: 'tab', "aria-controls" => "home", "data-toggle" => "tab") do
|
=link_to('#signup', role: 'tab', "aria-controls" => "home", "data-toggle" => "tab") do
|
||||||
= CONFIG['name']
|
= ENV['OSEM_NAME'] || 'OSEM'
|
||||||
Account
|
Account
|
||||||
%span.pull-right#account-already
|
%span.pull-right#account-already
|
||||||
=link_to('#signin', role: 'tab', "aria-controls" => "home", "data-toggle" => "tab") do
|
=link_to('#signin', role: 'tab', "aria-controls" => "home", "data-toggle" => "tab") do
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
- if !CONFIG['authentication']['ichain']['enabled']
|
- if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
|
||||||
= form_tag(new_user_session_path, class: 'form-horizontal') do
|
= form_tag(new_user_session_path, class: 'form-horizontal') do
|
||||||
%legend
|
%legend
|
||||||
%span
|
%span
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
%span.icon-bar
|
%span.icon-bar
|
||||||
%span.icon-bar
|
%span.icon-bar
|
||||||
%span.icon-bar
|
%span.icon-bar
|
||||||
= link_to CONFIG['name'], root_path, class: 'navbar-brand', title: 'Open Source Event Manager'
|
= link_to (ENV['OSEM_NAME'] || 'OSEM'), root_path, class: 'navbar-brand', title: 'Open Source Event Manager'
|
||||||
.collapse.navbar-collapse
|
.collapse.navbar-collapse
|
||||||
- if content_for :splash_nav
|
- if content_for :splash_nav
|
||||||
%ul.nav.navbar-nav#splash-nav
|
%ul.nav.navbar-nav#splash-nav
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
%li= link_to 'See all Comments', admin_comments_path(anchor: 'all_comments')
|
%li= link_to 'See all Comments', admin_comments_path(anchor: 'all_comments')
|
||||||
- else
|
- else
|
||||||
%ul.nav.navbar-nav.navbar-right
|
%ul.nav.navbar-nav.navbar-right
|
||||||
- if CONFIG['authentication']['ichain']['enabled']
|
- if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
|
||||||
%li{:class=> "#{active_nav_li(new_ichain_registration_path('user'))}"}
|
%li{:class=> "#{active_nav_li(new_ichain_registration_path('user'))}"}
|
||||||
= link_to(new_ichain_registration_path('user')) do
|
= link_to(new_ichain_registration_path('user')) do
|
||||||
%span.fa.fa-heart
|
%span.fa.fa-heart
|
||||||
|
|
@ -59,7 +59,7 @@
|
||||||
Sign In
|
Sign In
|
||||||
%span.caret
|
%span.caret
|
||||||
.dropdown-menu{:style => "padding: 17px; min-width: 225px;"}
|
.dropdown-menu{:style => "padding: 17px; min-width: 225px;"}
|
||||||
- if CONFIG['authentication']['ichain']['enabled']
|
- if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
|
||||||
= form_tag User.ichain_login_url do
|
= form_tag User.ichain_login_url do
|
||||||
= text_field_tag 'username', nil, id: 'user_ichain_email_dd', placeholder: 'Username'
|
= text_field_tag 'username', nil, id: 'user_ichain_email_dd', placeholder: 'Username'
|
||||||
= password_field_tag 'password', nil, id: 'user_ichain_password_dd', placeholder: 'Password'
|
= password_field_tag 'password', nil, id: 'user_ichain_password_dd', placeholder: 'Password'
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
- unless CONFIG['authentication']['ichain']['enabled']
|
- unless ENV['OSEM_ICHAIN_ENABLED'] == 'true'
|
||||||
%li
|
%li
|
||||||
= link_to(edit_user_registration_path) do
|
= link_to(edit_user_registration_path) do
|
||||||
%span.fa.fa-wrench
|
%span.fa.fa-wrench
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
%span.fa.fa-comment
|
%span.fa.fa-comment
|
||||||
My Submissions
|
My Submissions
|
||||||
%li
|
%li
|
||||||
- if CONFIG['authentication']['ichain']['enabled']
|
- if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
|
||||||
= link_to(destroy_user_ichain_session_path, :method=>'delete') do
|
= link_to(destroy_user_ichain_session_path, :method=>'delete') do
|
||||||
%span.fa.fa-minus
|
%span.fa.fa-minus
|
||||||
Sign out
|
Sign out
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
%head
|
%head
|
||||||
%meta{:charset => "utf-8"}
|
%meta{:charset => "utf-8"}
|
||||||
%meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"}
|
%meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"}
|
||||||
%title= content_for?(:title) ? yield(:title) : CONFIG['name']
|
%title= content_for?(:title) ? yield(:title) : (ENV['OSEM_NAME'] || 'OSEM')
|
||||||
%meta{:content => "", :name => "description"}
|
%meta{:content => "", :name => "description"}
|
||||||
%meta{:content => "", :name => "author"}
|
%meta{:content => "", :name => "author"}
|
||||||
= stylesheet_link_tag "application", :media => "all"
|
= stylesheet_link_tag "application", :media => "all"
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
= csrf_meta_tags
|
= csrf_meta_tags
|
||||||
:javascript
|
:javascript
|
||||||
window.liveSettings = {
|
window.liveSettings = {
|
||||||
api_key: "#{CONFIG['transifex_live_api_key']}",
|
api_key: "#{ENV['OSEM_TRANSIFEX_APIKEY']}",
|
||||||
picker: "bottom-right",
|
picker: "bottom-right",
|
||||||
detectlang: true,
|
detectlang: true,
|
||||||
autocollect: true
|
autocollect: true
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
%head
|
%head
|
||||||
%meta{:charset => "utf-8"}
|
%meta{:charset => "utf-8"}
|
||||||
%meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"}
|
%meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"}
|
||||||
%title= content_for?(:title) ? yield(:title) : CONFIG['name']
|
%title= content_for?(:title) ? yield(:title) : (ENV['OSEM_NAME'] || 'OSEM')
|
||||||
%meta{:content => "", :name => "description"}
|
%meta{:content => "", :name => "description"}
|
||||||
%meta{:content => "", :name => "author"}
|
%meta{:content => "", :name => "author"}
|
||||||
= stylesheet_link_tag "/stylesheets/schedule/jquery-ui-1.9.2.custom.min"
|
= stylesheet_link_tag "/stylesheets/schedule/jquery-ui-1.9.2.custom.min"
|
||||||
|
|
@ -17,4 +17,4 @@
|
||||||
= yield(:head)
|
= yield(:head)
|
||||||
%body
|
%body
|
||||||
.content
|
.content
|
||||||
= yield
|
= yield
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
%legend
|
%legend
|
||||||
%span
|
%span
|
||||||
=link_to('#signup', role: 'tab', 'aria-controls' => 'home', 'data-toggle' => 'tab') do
|
=link_to('#signup', role: 'tab', 'aria-controls' => 'home', 'data-toggle' => 'tab') do
|
||||||
= CONFIG['name']
|
= ENV['OSEM_NAME'] || 'OSEM'
|
||||||
Account
|
Account
|
||||||
%span.pull-right#account-already
|
%span.pull-right#account-already
|
||||||
=link_to('#signin', role: 'tab', 'aria-controls' => 'home', 'data-toggle' => 'tab') do
|
=link_to('#signin', role: 'tab', 'aria-controls' => 'home', 'data-toggle' => 'tab') do
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,10 @@ Osem::Application.configure do
|
||||||
config.eager_load = false
|
config.eager_load = false
|
||||||
|
|
||||||
# Set the detault url for action mailer
|
# 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
|
# Use omniauth mock credentials
|
||||||
OmniAuth.config.test_mode = true
|
OmniAuth.config.test_mode = true
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ Osem::Application.configure do
|
||||||
config.active_support.deprecation = :notify
|
config.active_support.deprecation = :notify
|
||||||
|
|
||||||
# Set the detault url for action mailer
|
# 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
|
# 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
|
# 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'],
|
password: CONFIG['MAIL_PASSWORD'],
|
||||||
authentication: CONFIG['MAIL_AUTHENTICATION']
|
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
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,24 +2,21 @@
|
||||||
# Many of these configuration options can be set straight in your model.
|
# Many of these configuration options can be set straight in your model.
|
||||||
|
|
||||||
Devise.setup do |config|
|
Devise.setup do |config|
|
||||||
# ==> Secret key, generate one with `rake secret`
|
|
||||||
config.secret_key = Rails.application.secrets.devise_secret_key
|
|
||||||
|
|
||||||
# ==> openIDs configuration
|
# ==> openIDs configuration
|
||||||
# Define the available openID providers that can be used to log in
|
# 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)
|
# 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 :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',
|
name: 'google',
|
||||||
scope: 'email'
|
scope: 'email'
|
||||||
config.omniauth :facebook, Rails.application.secrets.facebook_key, Rails.application.secrets.facebook_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, Rails.application.secrets.github_key, Rails.application.secrets.github_secret
|
config.omniauth :github, (ENV['OSEM_GITHUB_KEY'] || Rails.application.secrets.github_key), (ENV['OSEM_GITHUB_SECRET'] || Rails.application.secrets.github_secret)
|
||||||
|
|
||||||
# ==> Mailer Configuration
|
# ==> Mailer Configuration
|
||||||
# Configure the e-mail address which will be shown in Devise::Mailer,
|
# 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.
|
# 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.
|
# Configure the class responsible to send e-mails.
|
||||||
# config.mailer = "Devise::Mailer"
|
# config.mailer = "Devise::Mailer"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
HoptoadNotifier.configure do |config|
|
HoptoadNotifier.configure do |config|
|
||||||
# Change this to some sensible data for your errbit instance
|
# Change this to some sensible data for your errbit instance
|
||||||
config.api_key = Rails.application.secrets.errbit_key || ''
|
config.api_key = ENV['OSEM_ERRBIT_APIKEY'] || Rails.application.secrets.errbit_key || ''
|
||||||
config.host = Rails.application.secrets.errbit_host || ''
|
config.host = ENV['OSEM_ERRBIT_HOST']
|
||||||
if config.api_key.blank? || config.host.blank?
|
if config.api_key.blank? || config.host.blank?
|
||||||
config.development_environments = 'production development test'
|
config.development_environments = 'production development test'
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
Osem::Application.routes.draw do
|
Osem::Application.routes.draw do
|
||||||
|
|
||||||
if CONFIG['authentication']['ichain']['enabled']
|
if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
|
||||||
devise_for :users, controllers: { registrations: :registrations }
|
devise_for :users, controllers: { registrations: :registrations }
|
||||||
else
|
else
|
||||||
devise_for :users,
|
devise_for :users,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue