move loading rack ssl to an initializer, so we have EnviromentConfiguration and AppConfig. also, circumvent ssl requirement option is now back"
This commit is contained in:
parent
08adcf3e3e
commit
69e81a0dc3
3 changed files with 10 additions and 1 deletions
|
|
@ -196,6 +196,7 @@ defaults: &defaults
|
||||||
# is running on the default Redis port.
|
# is running on the default Redis port.
|
||||||
redis_location: ''
|
redis_location: ''
|
||||||
|
|
||||||
|
circumvent_ssl_requirement: false
|
||||||
|
|
||||||
# Web tracking
|
# Web tracking
|
||||||
|
|
||||||
|
|
|
||||||
1
config/initializers/enforce_ssl.rb
Normal file
1
config/initializers/enforce_ssl.rb
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Rails.application.config.middleware.insert_before(Rack::Runtime, Rack::SSL) if EnviromentConfiguration.enforce_ssl?
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
module EnviromentConfiguration
|
module EnviromentConfiguration
|
||||||
ARRAY_SEPERATOR = '%|%'
|
|
||||||
def self.heroku?
|
def self.heroku?
|
||||||
ENV['HEROKU']
|
ENV['HEROKU']
|
||||||
end
|
end
|
||||||
|
|
@ -29,6 +29,13 @@ module EnviromentConfiguration
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.enforce_ssl?
|
||||||
|
return false unless Rails.env == 'production'
|
||||||
|
return false if ENV['NO_SSL']
|
||||||
|
return false if AppConfig[:circumvent_ssl_requirement].present?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
def self.ca_cert_file_location
|
def self.ca_cert_file_location
|
||||||
if self.heroku?
|
if self.heroku?
|
||||||
"/usr/lib/ssl/certs/ca-certificates.crt"
|
"/usr/lib/ssl/certs/ca-certificates.crt"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue