mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Fixed all broken specs
Moved middleware config into authenticators
This commit is contained in:
@@ -121,6 +121,7 @@ module Discourse
|
||||
|
||||
unless Rails.env.test?
|
||||
require 'plugin'
|
||||
require_dependency 'auth'
|
||||
Discourse.activate_plugins!
|
||||
end
|
||||
|
||||
|
||||
11
config/initializers/09-omniauth.rb
Normal file
11
config/initializers/09-omniauth.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
require "openssl"
|
||||
require "openid_redis_store"
|
||||
|
||||
# if you need to test this and are having ssl issues see:
|
||||
# http://stackoverflow.com/questions/6756460/openssl-error-using-omniauth-specified-ssl-path-but-didnt-work
|
||||
|
||||
Rails.application.config.middleware.use OmniAuth::Builder do
|
||||
Discourse.authenticators.each do |authenticator|
|
||||
authenticator.register_middleware(self)
|
||||
end
|
||||
end
|
||||
@@ -1,72 +0,0 @@
|
||||
require "openssl"
|
||||
require "openid_redis_store"
|
||||
|
||||
# if you need to test this and are having ssl issues see:
|
||||
# http://stackoverflow.com/questions/6756460/openssl-error-using-omniauth-specified-ssl-path-but-didnt-work
|
||||
|
||||
Rails.application.config.middleware.use OmniAuth::Builder do
|
||||
|
||||
provider :open_id,
|
||||
:store => OpenID::Store::Redis.new($redis),
|
||||
:name => "google",
|
||||
:identifier => "https://www.google.com/accounts/o8/id",
|
||||
:require => "omniauth-openid"
|
||||
|
||||
provider :open_id,
|
||||
:store => OpenID::Store::Redis.new($redis),
|
||||
:name => "yahoo",
|
||||
:identifier => "https://me.yahoo.com",
|
||||
:require => "omniauth-openid"
|
||||
|
||||
Discourse.auth_providers.each do |p|
|
||||
if p.type == :open_id
|
||||
provider :open_id, {
|
||||
:name => p.name,
|
||||
:store => OpenID::Store::Redis.new($redis),
|
||||
:require => "omniauth-openid"
|
||||
}.merge(p.options)
|
||||
elsif p.type == :oauth2
|
||||
provider :oauth2,
|
||||
p.options[:client_id],
|
||||
p.options[:client_secret],
|
||||
{
|
||||
:name => p.name,
|
||||
:require => "omniauth-oauth2"
|
||||
}.merge(p.options)
|
||||
else
|
||||
provider p.type, *p.options
|
||||
end
|
||||
end
|
||||
|
||||
# lambda is required for proper multisite support,
|
||||
# without it subdomains will not function correctly
|
||||
provider :facebook,
|
||||
:setup => lambda { |env|
|
||||
strategy = env["omniauth.strategy"]
|
||||
strategy.options[:client_id] = SiteSetting.facebook_app_id
|
||||
strategy.options[:client_secret] = SiteSetting.facebook_app_secret
|
||||
},
|
||||
:scope => "email"
|
||||
|
||||
provider :twitter,
|
||||
:setup => lambda { |env|
|
||||
strategy = env["omniauth.strategy"]
|
||||
strategy.options[:consumer_key] = SiteSetting.twitter_consumer_key
|
||||
strategy.options[:consumer_secret] = SiteSetting.twitter_consumer_secret
|
||||
}
|
||||
|
||||
provider :github,
|
||||
:setup => lambda { |env|
|
||||
strategy = env["omniauth.strategy"]
|
||||
strategy.options[:client_id] = SiteSetting.github_client_id
|
||||
strategy.options[:client_secret] = SiteSetting.github_client_secret
|
||||
},
|
||||
:scope => "user:email"
|
||||
|
||||
provider :browser_id,
|
||||
:name => "persona"
|
||||
|
||||
provider :cas,
|
||||
:host => SiteSetting.cas_hostname
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user