Skip to content

Commit 66f4665

Browse files
committed
config/Use application credentials for different envs
1 parent 7c42a77 commit 66f4665

File tree

5 files changed

+151
-8
lines changed

5 files changed

+151
-8
lines changed

config/credentials.yml.enc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5J1hm3PZjrwJ5nDeWBOk0OaGx9yN768sqFotFsr9TGu19lj4SLSAjj7UZBucQncqrQBL7ZMprj+s0v57kr68mvkYUKQZcKvLyXFFi4HUGc6ZLiMvaXjmcYL0czypj5T7qmb2eA1w+jR+9T43CNSOs2WwR5cVgmRyqkr8qn3bOJZV3wKrwxVPMKiz/Psdf01tYvFxnaXwn7XB2jjPDW0j/BVf0pZpLg8JJql86HmUUbnRxcneXqj82eGGlubAs5BwXTRoNHpTO1HZk3VjcilXs5NMN2aez9wbZhHr63Db7h2itZ/riv5zkjjMCIbntjUw53NpryLNIlQL4zEQiSiQkP/6ePfGVU6eD6rDd5CyJ765yLftRLFkOMnJTLKuCTlpmLtXQA0wxabqisZpbvT4Xj699d8W8INveLAh9TRH/h4Y4WzjS7WqPQam1IAERAnpzfCnjCPe+seqUYQmF1dU3ef5Oxlz0o4YBaDBBQ==--wVy4RLCOhoOQts5b--UYytvnGBmR/To23uVD75FQ==
1+
PQznB7tzzXU8akEPdC7Pxq/Ut4qXC4Wa+YIFB/awfAHBrcMi8uZIYXmri1sVVOUL/o0NAnZ1BFzoDRx07kmdh6TSWVXC+h11Tz9AUewu1zpOiDC/7fTWeygBSUXPq+ItKsah2e5Wb+j4Ng+Mip9ISL+QX04ockjNgjdZwVJxxQNRSxbxPKpYOgLshB2kfCMELmGU9F9rk1+/fppiHk63TmipLXLAnFQSSSX7Yui+iTZDNRfzKUIgsQK5Z/Gj3r4Uf7och0asxQzleslwKGffN2XAsHCyuzF/PE9mh05G/vgvnPQZblLlcOL33qCZwe6U94ipz1hIGY5XzcD5Viae+VchRKGf287u5SUvLYWfdtD6R+vi2pib66U2mDVz5cQgtnjw4j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Gp7/WP1t9jlJNQz3l6dqvfbkE8MxOqj5h6uRuBtg9EQ9itrMXtYvZGoSmC8VwMzX2dLqgCPildlH9TJ4E9xMUUZ6hPcaiIYFwnDQtikG8/LV84bk06EA/bCG37R59bzDdtvtSMb98M2N8TYVKfskngi+5lfNaGh/IKP20WSQ5Fi/9Vw2UZGIhgoZXvv5sk8SwSMb0lJAieIJiqUh5wYJw8GJZ654PG+ba4CXArqcrTzK1RDJVhRJdQM1lRwytVd2orkgIK88F+o1RJlXhffw6PEGTDyu7W+777OeWUQi3VSWcVZKqNI46T0YLEdAeSKJyQ4fF7JoZsEFqel4K2nvMKrmbzBJqHFLA2dSGKtWDl0mVjGZkO04q5DaY4qNCVMK8KHPW0/T2lMQO7u7jp64AgU9AR4YRSxBMOttKKksDXYERlmAp3InXx7mfa8Qt+Z+e6Pgzww48Jnk/cqbRbgw1alanvaXiwbcLFVaZp1UbJF+Z376j0NnEr19OlCiTtUB9glC0YLw7GXV8+0a+P+i84Diw/3tqPZ9O6uHX1saJOekZUhi83visa1HktEwVvxYjBjDBeMoU373wLMpsEZPlqDZIakE6GXY4q5dEYNL1KFoMpUaOIGoYnb0ZcHR9yzakkV/F7t9/LMn05u4j2p0nctS1VeLyH94kcs2KIv5NcejpD1dIOtTJ+PykS4Qc4xqeL0j+9Uced8Rsd--IVHXAZOj7H/0w/jQ--JQmRSxKly7QcRXNVNFIeaQ==

config/environments/production.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
:port => 587,
8484
:authentication => :plain,
8585
:user_name => 'apikey',
86-
:password => ENV['SENDGRID_API_KEY'],
86+
:password => Rails.application.credentials.dig(Rails.env.to_sym, :sendgrid, :password),
8787
:domain => 'heroku.com'
8888
}
8989

config/environments/staging.rb

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
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+
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
18+
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
19+
# config.require_master_key = true
20+
21+
# Disable serving static files from the `/public` folder by default since
22+
# Apache or NGINX already handles this.
23+
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
24+
25+
# Compress CSS using a preprocessor.
26+
# config.assets.css_compressor = :sass
27+
28+
# Do not fallback to assets pipeline if a precompiled asset is missed.
29+
config.assets.compile = false
30+
31+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
32+
# config.action_controller.asset_host = 'http://assets.example.com'
33+
34+
# Specifies the header that your server uses for sending files.
35+
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
36+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
37+
38+
# Store uploaded files on the local file system (see config/storage.yml for options).
39+
config.active_storage.service = :amazon
40+
41+
# Mount Action Cable outside main process or domain.
42+
# config.action_cable.mount_path = nil
43+
# config.action_cable.url = 'wss://example.com/cable'
44+
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
45+
46+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
47+
# config.force_ssl = true
48+
49+
# Use the lowest log level to ensure availability of diagnostic information
50+
# when problems arise.
51+
config.log_level = :debug
52+
53+
# Prepend all log lines with the following tags.
54+
config.log_tags = [ :request_id ]
55+
56+
# Use a different cache store in production.
57+
# config.cache_store = :mem_cache_store
58+
59+
# Use a real queuing backend for Active Job (and separate queues per environment).
60+
# config.active_job.queue_adapter = :resque
61+
# config.active_job.queue_name_prefix = "snippet_app_production"
62+
63+
config.action_mailer.perform_caching = false
64+
65+
# config.action_mailer.delivery_method = :smtp
66+
# config.action_mailer.default_url_options = { host: "https://www.snippetsafe.com" }
67+
# config.smtp_settings = {
68+
# :user_name => ENV['SENDGRID_USERNAME'],
69+
# :password => ENV['SENDGRID_PASSWORD'],
70+
# :domain => 'snippetsafe.com',
71+
# :address => 'smtp.sendgrid.net',
72+
# :port => 587,
73+
# :authentication => :plain,
74+
# :enable_starttls_auto => true
75+
# }
76+
77+
config.action_mailer.raise_delivery_errors = true
78+
config.action_mailer.default_url_options = { :host => 'snippet-safe-staging.herokuapp.com/' }
79+
config.action_mailer.perform_deliveries = true
80+
81+
ActionMailer::Base.smtp_settings = {
82+
:address => 'smtp.sendgrid.net',
83+
:port => 587,
84+
:authentication => :plain,
85+
:user_name => 'apikey',
86+
:password => Rails.application.credentials.dig(Rails.env.to_sym, :sendgrid, :password),
87+
:domain => 'heroku.com'
88+
}
89+
90+
ActionMailer::Base.delivery_method = :smtp
91+
92+
# Ignore bad email addresses and do not raise email delivery errors.
93+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
94+
# config.action_mailer.raise_delivery_errors = false
95+
96+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
97+
# the I18n.default_locale when a translation cannot be found).
98+
config.i18n.fallbacks = true
99+
100+
# Send deprecation notices to registered listeners.
101+
config.active_support.deprecation = :notify
102+
103+
# Use default logging formatter so that PID and timestamp are not suppressed.
104+
config.log_formatter = ::Logger::Formatter.new
105+
106+
# Use a different logger for distributed setups.
107+
# require 'syslog/logger'
108+
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
109+
110+
if ENV["RAILS_LOG_TO_STDOUT"].present?
111+
logger = ActiveSupport::Logger.new(STDOUT)
112+
logger.formatter = config.log_formatter
113+
config.logger = ActiveSupport::TaggedLogging.new(logger)
114+
end
115+
116+
# Do not dump schema after migrations.
117+
config.active_record.dump_schema_after_migration = false
118+
119+
# Inserts middleware to perform automatic connection switching.
120+
# The `database_selector` hash is used to pass options to the DatabaseSelector
121+
# middleware. The `delay` is used to determine how long to wait after a write
122+
# to send a subsequent read to the primary.
123+
#
124+
# The `database_resolver` class is used by the middleware to determine which
125+
# database is appropriate to use based on the time delay.
126+
#
127+
# The `database_resolver_context` class is used by the middleware to set
128+
# timestamps for the last write to the primary. The resolver uses the context
129+
# class timestamps to determine how long to wait before reading from the
130+
# replica.
131+
#
132+
# By default Rails will store a last write timestamp in the session. The
133+
# DatabaseSelector middleware is designed as such you can define your own
134+
# strategy for connection switching and pass that into the middleware through
135+
# these configuration options.
136+
# config.active_record.database_selector = { delay: 2.seconds }
137+
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
138+
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
139+
end
140+

config/initializers/devise.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,13 @@
259259
# ==> OmniAuth
260260
# Add a new OmniAuth provider. Check the wiki for more information on setting
261261
# up on your models and hooks.
262-
config.omniauth :github, 'c9ba150c81465d914e7c', '9ef7c9d7a3d348911dc1108c71c3769c835c5374', scope: 'user'
262+
github_client_id = Rails.application.credentials.dig(Rails.env.to_sym, :github, :client_id)
263+
github_client_secret = Rails.application.credentials.dig(Rails.env.to_sym, :github, :client_secret)
264+
265+
config.omniauth :github, github_client_id, github_client_secret, scope: 'user'
263266

264267
OmniAuth.config.before_request_phase do |env|
265-
env['HTTP_REFERER'] = nil
268+
env['HTTP_REFERER'] = nil
266269
end
267270

268271
# ==> Warden configuration

config/storage.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ local:
99
# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
1010
amazon:
1111
service: S3
12-
access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
13-
secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
14-
region: eu-west-2
15-
bucket: snippet-production
12+
access_key_id: <%= Rails.application.credentials.dig(Rails.env.to_sym, :aws, :access_key_id) %>
13+
secret_access_key: <%= Rails.application.credentials.dig(Rails.env.to_sym, :aws, :secret_access_key) %>
14+
region: <%= Rails.application.credentials.dig(Rails.env.to_sym, :aws, :region) %>
15+
bucket: <%= Rails.application.credentials.dig(Rails.env.to_sym, :aws, :bucket) %>
1616

1717
# Remember not to checkin your GCS keyfile to a repository
1818
# google:

0 commit comments

Comments
 (0)