2013-08-01 19:47:54 -04:00
|
|
|
require "openssl"
|
|
|
|
require "openid_redis_store"
|
2013-02-12 01:51:44 -05:00
|
|
|
|
2013-02-14 14:11:13 -05:00
|
|
|
# if you need to test this and are having ssl issues see:
|
2013-02-13 17:12:20 -05:00
|
|
|
# http://stackoverflow.com/questions/6756460/openssl-error-using-omniauth-specified-ssl-path-but-didnt-work
|
2013-02-12 01:51:44 -05:00
|
|
|
|
|
|
|
Rails.application.config.middleware.use OmniAuth::Builder do
|
2013-02-13 17:12:20 -05:00
|
|
|
|
2013-02-14 14:11:13 -05:00
|
|
|
provider :open_id,
|
2013-03-24 20:21:18 -04:00
|
|
|
:store => OpenID::Store::Redis.new($redis),
|
2013-08-01 19:47:54 -04:00
|
|
|
:name => "google",
|
|
|
|
:identifier => "https://www.google.com/accounts/o8/id",
|
|
|
|
:require => "omniauth-openid"
|
2013-02-13 17:12:20 -05:00
|
|
|
|
2013-02-14 14:11:13 -05:00
|
|
|
provider :open_id,
|
2013-03-24 20:21:18 -04:00
|
|
|
:store => OpenID::Store::Redis.new($redis),
|
2013-08-01 19:47:54 -04:00
|
|
|
:name => "yahoo",
|
|
|
|
:identifier => "https://me.yahoo.com",
|
|
|
|
:require => "omniauth-openid"
|
2013-02-13 17:12:20 -05:00
|
|
|
|
2013-08-01 01:59:57 -04:00
|
|
|
Discourse.auth_providers.each do |p|
|
|
|
|
if p.type == :open_id
|
|
|
|
provider :open_id, {
|
|
|
|
:name => p.name,
|
|
|
|
:store => OpenID::Store::Redis.new($redis),
|
2013-08-01 19:47:54 -04:00
|
|
|
:require => "omniauth-openid"
|
2013-08-01 01:59:57 -04:00
|
|
|
}.merge(p.options)
|
2013-08-18 00:43:59 -04:00
|
|
|
elsif p.type == :oauth2
|
|
|
|
provider :oauth2,
|
|
|
|
p.options[:client_id],
|
|
|
|
p.options[:client_secret],
|
|
|
|
{
|
|
|
|
:name => p.name,
|
|
|
|
:require => "omniauth-oauth2"
|
|
|
|
}.merge(p.options)
|
2013-08-01 01:59:57 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# lambda is required for proper multisite support,
|
|
|
|
# without it subdomains will not function correctly
|
2013-02-14 14:11:13 -05:00
|
|
|
provider :facebook,
|
2013-03-24 20:21:18 -04:00
|
|
|
:setup => lambda { |env|
|
2013-08-01 19:47:54 -04:00
|
|
|
strategy = env["omniauth.strategy"]
|
2013-03-24 20:21:18 -04:00
|
|
|
strategy.options[:client_id] = SiteSetting.facebook_app_id
|
|
|
|
strategy.options[:client_secret] = SiteSetting.facebook_app_secret
|
|
|
|
},
|
|
|
|
:scope => "email"
|
2013-02-13 17:12:20 -05:00
|
|
|
|
2013-02-14 14:11:13 -05:00
|
|
|
provider :twitter,
|
2013-03-24 20:21:18 -04:00
|
|
|
:setup => lambda { |env|
|
2013-08-01 19:47:54 -04:00
|
|
|
strategy = env["omniauth.strategy"]
|
2013-03-24 20:21:18 -04:00
|
|
|
strategy.options[:consumer_key] = SiteSetting.twitter_consumer_key
|
|
|
|
strategy.options[:consumer_secret] = SiteSetting.twitter_consumer_secret
|
|
|
|
}
|
2013-02-13 17:12:20 -05:00
|
|
|
|
2013-02-25 23:28:32 -05:00
|
|
|
provider :github,
|
2013-03-24 20:21:18 -04:00
|
|
|
:setup => lambda { |env|
|
2013-08-01 19:47:54 -04:00
|
|
|
strategy = env["omniauth.strategy"]
|
2013-03-24 20:21:18 -04:00
|
|
|
strategy.options[:client_id] = SiteSetting.github_client_id
|
|
|
|
strategy.options[:client_secret] = SiteSetting.github_client_secret
|
2013-08-01 19:47:54 -04:00
|
|
|
},
|
2013-08-01 20:03:29 -04:00
|
|
|
:scope => "user:email"
|
2013-02-25 23:28:32 -05:00
|
|
|
|
2013-02-25 19:10:16 -05:00
|
|
|
provider :browser_id,
|
2013-08-01 19:47:54 -04:00
|
|
|
:name => "persona"
|
2013-02-25 19:10:16 -05:00
|
|
|
|
2013-05-23 16:40:50 -04:00
|
|
|
provider :cas,
|
|
|
|
:host => SiteSetting.cas_hostname
|
|
|
|
|
2013-02-13 17:12:20 -05:00
|
|
|
end
|