Skip to content

Commit 23c1085

Browse files
authored
Merge pull request #409 from coderdojo-japan/test-review-app
Set AUTH for Staging apps in Heroku Review
2 parents c12dca4 + 246f359 commit 23c1085

File tree

5 files changed

+116
-0
lines changed

5 files changed

+116
-0
lines changed

app.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
},
8181
"name": "coderdojo.jp",
8282
"scripts": {
83+
"postdeploy": "bundle exec rails db:setup && bundle exec rails dojos:update_db_by_yaml && bundle exec rails dojo_event_services:upsert"
8384
},
8485
"stack": "heroku-18"
8586
}

app/controllers/application_controller.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
class ApplicationController < ActionController::Base
2+
http_basic_authenticate_with name: ENV['BASIC_AUTH_NAME'],
3+
password: ENV['BASIC_AUTH_PASSWORD'] if Rails.env.staging?
4+
25
before_action :store_location , unless: :login_page_access?
36

47
# Prevent CSRF attacks by raising an exception.

config/database.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,9 @@ test:
8282
# production:
8383
# url: <%= ENV['DATABASE_URL'] %>
8484
#
85+
staging:
86+
<<: *default
87+
database: coderdojo_jp_staging
88+
8589
production:
8690
url: <%= ENV['DATABASE_URL'] %>

config/environments/staging.rb

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
Rails.application.configure do
2+
# Settings specified here will take precedence over those in config/application.rb.
3+
4+
# Code is not reloaded between requests.
5+
config.cache_classes = true
6+
7+
# Eager load code on boot. This eager loads most of Rails and
8+
# your application in memory, allowing both threaded web servers
9+
# and those relying on copy on write to perform better.
10+
# Rake tasks automatically ignore this option for performance.
11+
config.eager_load = true
12+
13+
# Full error reports are disabled and caching is turned on.
14+
config.consider_all_requests_local = false
15+
config.action_controller.perform_caching = true
16+
17+
# Attempt to read encrypted secrets from `config/secrets.yml.enc`.
18+
# Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
19+
# `config/secrets.yml.key`.
20+
config.read_encrypted_secrets = true
21+
22+
# Disable serving static files from the `/public` folder by default since
23+
# Apache or NGINX already handles this.
24+
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
25+
26+
# Debug mode disables concatenation and preprocessing of assets.
27+
# This option may cause significant delays in view rendering with a large
28+
# number of complex assets.
29+
config.assets.debug = true
30+
31+
# Suppress logger output for asset requests.
32+
#config.assets.quiet = true
33+
34+
# Compress JavaScripts and CSS.
35+
config.assets.js_compressor = Sprockets::UglifierCompressor.new(comments: :copyright)
36+
# config.assets.css_compressor = :sass
37+
38+
# Do not fallback to assets pipeline if a precompiled asset is missed.
39+
config.assets.compile = false
40+
41+
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
42+
43+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
44+
# config.action_controller.asset_host = 'http://assets.example.com'
45+
46+
# Specifies the header that your server uses for sending files.
47+
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
48+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
49+
50+
# Mount Action Cable outside main process or domain
51+
# config.action_cable.mount_path = nil
52+
# config.action_cable.url = 'wss://example.com/cable'
53+
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
54+
55+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
56+
config.force_ssl = true
57+
58+
# Use the lowest log level to ensure availability of diagnostic information
59+
# when problems arise.
60+
config.log_level = :debug
61+
62+
# Prepend all log lines with the following tags.
63+
config.log_tags = [ :request_id ]
64+
65+
# Use a different cache store in production.
66+
# config.cache_store = :mem_cache_store
67+
# config.cache_store = :memory_store
68+
69+
# Use a real queuing backend for Active Job (and separate queues per environment)
70+
# config.active_job.queue_adapter = :resque
71+
# config.active_job.queue_name_prefix = "coderdojo_jp_#{Rails.env}"
72+
config.action_mailer.perform_caching = false
73+
74+
# Ignore bad email addresses and do not raise email delivery errors.
75+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
76+
# config.action_mailer.raise_delivery_errors = false
77+
78+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
79+
# the I18n.default_locale when a translation cannot be found).
80+
config.i18n.fallbacks = true
81+
82+
# Send deprecation notices to registered listeners.
83+
config.active_support.deprecation = :notify
84+
85+
# Use default logging formatter so that PID and timestamp are not suppressed.
86+
config.log_formatter = ::Logger::Formatter.new
87+
88+
# Use a different logger for distributed setups.
89+
# require 'syslog/logger'
90+
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
91+
92+
if ENV["RAILS_LOG_TO_STDOUT"].present?
93+
logger = ActiveSupport::Logger.new(STDOUT)
94+
logger.formatter = config.log_formatter
95+
config.logger = ActiveSupport::TaggedLogging.new(logger)
96+
end
97+
98+
# Do not dump schema after migrations.
99+
config.active_record.dump_schema_after_migration = false
100+
101+
# Redirect if not in correct domains
102+
config.middleware.use Rack::HostRedirect, {
103+
%w(coderdojo-japan.herokuapp.com www.coderdojo.jp) => 'coderdojo.jp'
104+
}
105+
end

config/secrets.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ development:
2323
test:
2424
secret_key_base: 7ba3d6d2a7c7089b9ec2d21821c88cef5801cf32e4f9c4c0908456c3319d3bd651c8601b04625c2a03d3c16d1eb37833f1ae23a34586352eb6ab9d06999af583
2525

26+
staging:
27+
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
28+
2629
# Do not keep production secrets in the unencrypted secrets file.
2730
# Instead, either read values from the environment.
2831
# Or, use `bin/rails secrets:setup` to configure encrypted secrets

0 commit comments

Comments
 (0)