From ee5d48d4940a136283c1d7b2be47af93888edf10 Mon Sep 17 00:00:00 2001 From: Henne Vogelsang Date: Mon, 12 May 2014 18:32:26 +0200 Subject: [PATCH 1/2] Migrate all secrets to config/secrets.yml --- .gitignore | 1 + .travis.yml | 1 + config/config.yml.example | 7 +------ config/environment.rb | 1 - config/initializers/devise.rb | 2 +- config/initializers/hoptoad.rb | 10 +++++----- config/initializers/secret_token.rb | 7 ------- config/secrets.yml.example | 20 ++++++++++++++++++++ 8 files changed, 29 insertions(+), 20 deletions(-) delete mode 100644 config/initializers/secret_token.rb create mode 100644 config/secrets.yml.example diff --git a/.gitignore b/.gitignore index 69669e6c..a9ebd7f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ config/application.rb config/config.yml +config/secrets.yml config/database.yml /vendor/cache /vendor/cache-old diff --git a/.travis.yml b/.travis.yml index bb77e858..94148e6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ before_install: before_script: - cp config/database.yml.example config/database.yml - cp config/config.yml.example config/config.yml + - cp config/secrets.yml.example config/secrets.yml - RAILS_ENV=test bundle exec rake db:migrate --trace script: - bundle exec rspec --color --format documentation diff --git a/config/config.yml.example b/config/config.yml.example index f2e72703..c0c98b6d 100644 --- a/config/config.yml.example +++ b/config/config.yml.example @@ -5,14 +5,9 @@ defaults: &defaults devise_mail_sender: "no-reply@localhost" # The hostname to be used when building the URL in the emails url_for_emails: "localhost:3000" - # A secret key for your rails app. You can generate one with 'rake secret' - secret_key: 12345 - # A secret key. You can generate one with 'rake secret' - devise_secret_key: '12345' # errbit configuration, get your own instance: https://github.com/errbit/errbit - #errbit_key: 123456789101112131415 + #errbit_key: See config/secrets.yml #errbit_host: errbit.exmaple.com - cookies_secret_token: 'secretstringwhichshouldbechanged' development: <<: *defaults diff --git a/config/environment.rb b/config/environment.rb index 2a233acc..6b0a63d2 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -12,4 +12,3 @@ end # Initialize the rails application Osem::Application.initialize! -Osem::Application.config.secret_keybase = CONFIG['secret_key'] diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 77208236..2dc7d680 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -2,7 +2,7 @@ # 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 = CONFIG['devise_secret_key'] + config.secret_key = Rails.application.secrets.devise_secret_key # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, diff --git a/config/initializers/hoptoad.rb b/config/initializers/hoptoad.rb index 970310a8..14780578 100644 --- a/config/initializers/hoptoad.rb +++ b/config/initializers/hoptoad.rb @@ -1,11 +1,11 @@ HoptoadNotifier.configure do |config| # Change this to some sensible data for your errbit instance - config.api_key = CONFIG["errbit_key"] || "" - config.host = CONFIG["errbit_host"] || "" + config.api_key = Rails.application.secrets.errbit_key || '' + config.host = CONFIG['errbit_host'] || '' if config.api_key.blank? || config.host.blank? - config.development_environments = "production development test" + config.development_environments = 'production development test' else - config.development_environments = "development test" + config.development_environments = 'development test' end config.ignore_only = %w{ @@ -14,7 +14,7 @@ HoptoadNotifier.configure do |config| config.ignore_by_filter do |exception_data| ret=false - if exception_data[:error_class] == "ActionController::RoutingError" + if exception_data[:error_class] == 'ActionController::RoutingError' message = exception_data[:error_message] ret=true if message =~ %r{\[GET\]} end diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb deleted file mode 100644 index 98825f4a..00000000 --- a/config/initializers/secret_token.rb +++ /dev/null @@ -1,7 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Your secret key for verifying the integrity of signed cookies. -# If you change this key, all old signed cookies will become invalid! -# Make sure the secret is at least 30 characters and all random, -# no regular words or you'll be exposed to dictionary attacks. -Osem::Application.config.secret_token = CONFIG['cookies_secret_token'] diff --git a/config/secrets.yml.example b/config/secrets.yml.example new file mode 100644 index 00000000..d88180d4 --- /dev/null +++ b/config/secrets.yml.example @@ -0,0 +1,20 @@ +defaults: &defaults + # You can generate secret keys with 'rake secret' + + # For rails cookies + secret_key_base: '12345' + + # For devise login tokens + devise_secret_key: '12345' + + # Your errbit API key + # errbit_key: '12345' + +development: + <<: *defaults + +test: + <<: *defaults + +production: + <<: *defaults From 2ca99e7ab9b70e151d093f189dc2b8cad5252ba4 Mon Sep 17 00:00:00 2001 From: Chrisbr Date: Mon, 12 May 2014 18:35:28 +0200 Subject: [PATCH 2/2] Fix accept event workflow --- app/controllers/admin/events_controller.rb | 3 -- app/controllers/admin/schedule_controller.rb | 1 - app/views/admin/events/index.html.haml | 41 ++++++++++++-------- app/views/proposal/index.html.haml | 9 +++-- 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/app/controllers/admin/events_controller.rb b/app/controllers/admin/events_controller.rb index 81a0cdb4..9e5b38bc 100644 --- a/app/controllers/admin/events_controller.rb +++ b/app/controllers/admin/events_controller.rb @@ -113,12 +113,10 @@ class Admin::EventsController < ApplicationController flash[:notice] = "Update not successful." end - expire_page :controller => '/schedule', :action => :index redirect_back_or_to(admin_conference_event_path(@conference.short_title, @event)) end def create - expire_page :controller => '/schedule', :action => :index end def update_state @@ -127,7 +125,6 @@ class Admin::EventsController < ApplicationController redirect_to(admin_conference_events_path(:conference_id => @conference.short_title), :notice => "Update Email Template before Sending Mails") and return end event.send(:"#{params[:transition]}!", :send_mail => params[:send_mail]) - expire_page :controller => '/schedule', :action => :index redirect_to(admin_conference_events_path(:conference_id => @conference.short_title), :notice => "Updated state") end diff --git a/app/controllers/admin/schedule_controller.rb b/app/controllers/admin/schedule_controller.rb index b8f673ee..d35f0b15 100644 --- a/app/controllers/admin/schedule_controller.rb +++ b/app/controllers/admin/schedule_controller.rb @@ -47,7 +47,6 @@ class Admin::ScheduleController < ApplicationController startTime = DateTime.strptime(time, "%Y-%m-%d %k:%M") event.start_time = startTime event.save! - expire_page :controller => '/schedule', :action => :index render :json => {"status" => "ok"} end diff --git a/app/views/admin/events/index.html.haml b/app/views/admin/events/index.html.haml index dca7aacb..6b608947 100644 --- a/app/views/admin/events/index.html.haml +++ b/app/views/admin/events/index.html.haml @@ -106,26 +106,35 @@ %ul.dropdown-menu - if event.transition_possible? :accept - %li= link_to "Accept event (no email)", update_state_admin_conference_event_path(@conference.short_title, event, :transition => :accept, :send_mail => false), - :method => :put, :hint => "Accept this event without sending an automated email." - %li= link_to "Accept event (WITH email)", update_state_admin_conference_event_path(@conference.short_title, event, :transition => :accept, :send_mail => true), - :method => :put, :hint => "Accept this event and send an automated email." + %li= link_to 'Accept event (no email)', + update_state_admin_conference_event_path(@conference.short_title, event, transition: :accept, send_mail: false), + method: :patch, hint: 'Accept this event without sending an automated email.' + %li= link_to 'Accept event (WITH email)', + update_state_admin_conference_event_path(@conference.short_title, event, transition: :accept, send_mail: true), + method: :patch, hint: 'Accept this event and send an automated email.' - if event.transition_possible? :reject - %li= link_to "Reject event (no email)", update_state_admin_conference_event_path(@conference.short_title, event, :transition => :reject, :send_mail => false), - :method => :put, :confirm => "Are you sure?", - :hint => "Reject this event without sending an automated email." - %li= link_to "Reject event (WITH email)", update_state_admin_conference_event_path(@conference.short_title, event, :transition => :reject, :send_mail => true), - :method => :put, :confirm => "Are you sure?", - :hint => "Reject this event and send an automated email." + %li= link_to 'Reject event (no email)', + update_state_admin_conference_event_path(@conference.short_title, event, transition: :reject, send_mail: false), + method: :patch, confirm: 'Are you sure?', + hint: 'Reject this event without sending an automated email.' + %li= link_to 'Reject event (WITH email)', + update_state_admin_conference_event_path(@conference.short_title, event, transition: :reject, send_mail: true), + method: :patch, confirm: 'Are you sure?', + hint: 'Reject this event and send an automated email.' - if event.transition_possible? :start_review - %li= link_to "Start review", update_state_admin_conference_event_path(@conference.short_title, event, :transition => :start_review), - :method => :put + %li= link_to 'Start review', + update_state_admin_conference_event_path(@conference.short_title, event, transition: :start_review), + method: :patch - if event.transition_possible? :confirm - %li= link_to "Confirm event", update_state_admin_conference_event_path(@conference.short_title, event, :transition => :confirm), - :method => :put, :hint => "Confirm that the speaker(s) will be present and that the event will actually take place." + %li= link_to 'Confirm event', + update_state_admin_conference_event_path(@conference.short_title, event, transition: :confirm), + method: :patch, + hint: 'Confirm that the speaker(s) will be present and that the event will actually take place.' - if event.transition_possible? :cancel - %li= link_to "Cancel event", update_state_admin_conference_event_path(@conference.short_title, event, :transition => :cancel), - :method => :put, :hint => "Mark this event as cancelled. Usually this means that the speakers had to cancel their appearance." + %li= link_to 'Cancel event', + update_state_admin_conference_event_path(@conference.short_title, event, :transition => :cancel), + method: :patch, + hint: 'Mark this event as cancelled. Usually this means that the speakers had to cancel their appearance.' :javascript $(document).ready(function() { diff --git a/app/views/proposal/index.html.haml b/app/views/proposal/index.html.haml index 33cd0828..3d820f50 100644 --- a/app/views/proposal/index.html.haml +++ b/app/views/proposal/index.html.haml @@ -28,7 +28,8 @@ %td .pull-right - if event.transition_possible? :confirm - = link_to "Confirm", conference_proposal_confirm_path(@conference.short_title, event, :send_mail=>false), :method => :put, :class => "btn btn-mini btn-success" - = link_to "Edit", edit_conference_proposal_path(@conference.short_title, event.id), :class => "btn btn-mini btn-primary" - = link_to "Withdraw", conference_proposal_path(@conference.short_title, event.id), :method => :delete, - :confirm => "Are you sure you want to withdraw this proposal?", :class => "btn btn-mini btn-danger" + = link_to 'Confirm', + conference_proposal_confirm_path(@conference.short_title, event, send_mail: false), method: :patch, class: 'btn btn-mini btn-success' + = link_to 'Edit', edit_conference_proposal_path(@conference.short_title, event.id), class: 'btn btn-mini btn-primary' + = link_to 'Withdraw', conference_proposal_path(@conference.short_title, event.id), method: :delete, + confirm: 'Are you sure you want to withdraw this proposal?', class: 'btn btn-mini btn-danger'