21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/heroku/bouncer/builder.rb', line 21
def self.(options)
oauth = options[:oauth] || {}
id = oauth[:id]
secret = oauth[:secret]
scope = oauth[:scope] || 'identity'
if id.nil? && (ENV.has_key?('HEROKU_ID') || ENV.has_key?('HEROKU_OAUTH_ID'))
$stderr.puts "[warn] heroku-bouncer: HEROKU_ID or HEROKU_OAUTH_ID detected in environment, please pass in :oauth hash instead"
id = ENV['HEROKU_OAUTH_ID'] || ENV['HEROKU_ID']
end
if secret.nil? && (ENV.has_key?('HEROKU_SECRET') || ENV.has_key?('HEROKU_OAUTH_SECRET'))
$stderr.puts "[warn] heroku-bouncer: HEROKU_SECRET or HEROKU_OAUTH_SECRET detected in environment, please pass in :oauth hash instead"
secret = ENV['HEROKU_OAUTH_SECRET'] || ENV['HEROKU_SECRET']
end
if id.nil? || secret.nil? || id.empty? || secret.empty?
$stderr.puts "[fatal] heroku-bouncer: OAuth ID or secret not set, middleware disabled"
options[:disabled] = true
end
if options[:secret].nil?
if ENV.has_key?('COOKIE_SECRET')
$stderr.puts "[warn] heroku-bouncer: COOKIE_SECRET detected in environment, please pass in :secret instead"
options[:secret] = ENV['COOKIE_SECRET']
else
$stderr.puts "[warn] heroku-bouncer: :secret is missing, using id + secret"
options[:secret] = id.to_s + secret.to_s
end
end
[id, secret, scope]
end
|