2018-07-24 20:21:33 +08:00
|
|
|
Api.configure do |config|
|
|
|
|
if ENV['CORE_API_SIGN_ALG']
|
|
|
|
config.core_api_sign_alg = ENV['CORE_API_SIGN_ALG']
|
|
|
|
end
|
|
|
|
if ENV['CORE_API_TOKEN_TTL']
|
2018-08-17 17:59:47 +08:00
|
|
|
config.core_api_token_ttl = ENV['CORE_API_TOKEN_TTL'].to_i.seconds
|
2018-07-24 20:21:33 +08:00
|
|
|
end
|
|
|
|
if ENV['CORE_API_TOKEN_ISS']
|
|
|
|
config.core_api_token_iss = ENV['CORE_API_TOKEN_ISS']
|
|
|
|
end
|
|
|
|
|
2018-12-17 22:15:56 +08:00
|
|
|
config.core_api_rate_limit =
|
|
|
|
ENV['CORE_API_RATE_LIMIT'] ? ENV['CORE_API_RATE_LIMIT'].to_i : 1000
|
2018-10-11 15:48:06 +08:00
|
|
|
|
2019-01-04 17:44:38 +08:00
|
|
|
config.core_api_v1_enabled = true if ENV['CORE_API_V1_ENABLED']
|
2018-08-24 22:41:26 +08:00
|
|
|
|
2019-01-04 17:44:38 +08:00
|
|
|
Paperclip::DataUriAdapter.register if ENV['CORE_API_V1_ENABLED']
|
2018-08-22 17:38:39 +08:00
|
|
|
|
2018-07-24 20:21:33 +08:00
|
|
|
vars = ENV.select { |name, _| name =~ /^[[:alnum:]]*_AZURE_AD_APP_ID/ }
|
|
|
|
vars.each do |name, value|
|
|
|
|
app_name = name.sub('_AZURE_AD_APP_ID', '')
|
|
|
|
config.azure_ad_apps[value] = {}
|
|
|
|
|
|
|
|
iss = ENV["#{app_name}_AZURE_AD_ISS"]
|
|
|
|
raise StandardError, "No ISS for #{app_name} Azure app" unless iss
|
|
|
|
config.azure_ad_apps[value][:iss] = iss
|
|
|
|
|
|
|
|
conf_url = ENV["#{app_name}_AZURE_AD_CONF_URL"]
|
|
|
|
raise StandardError, "No CONF_URL for #{app_name} Azure app" unless conf_url
|
|
|
|
config.azure_ad_apps[value][:conf_url] = conf_url
|
|
|
|
|
|
|
|
provider = ENV["#{app_name}_AZURE_AD_PROVIDER_NAME"]
|
|
|
|
unless provider
|
|
|
|
raise StandardError, "No PROVIDER_NAME for #{app_name} Azure app"
|
|
|
|
end
|
|
|
|
config.azure_ad_apps[value][:provider] = provider
|
|
|
|
end
|
|
|
|
end
|