correct multisite functionality for omniauth

This commit is contained in:
Sam 2013-03-24 17:21:18 -07:00
parent deb603f41c
commit 988a712c77
2 changed files with 28 additions and 17 deletions

View file

@ -100,7 +100,7 @@ end
group :development do group :development do
gem 'better_errors' gem 'better_errors'
gem 'binding_of_caller' # I tried adding this and got an occational crash gem 'binding_of_caller'
gem 'librarian', '>= 0.0.25', require: false gem 'librarian', '>= 0.0.25', require: false
gem 'pry-rails' gem 'pry-rails'
end end

View file

@ -7,31 +7,42 @@ require 'openid_redis_store'
Rails.application.config.middleware.use OmniAuth::Builder do Rails.application.config.middleware.use OmniAuth::Builder do
provider :open_id, provider :open_id,
store: OpenID::Store::Redis.new($redis), :store => OpenID::Store::Redis.new($redis),
name: 'google', :name => 'google',
identifier: 'https://www.google.com/accounts/o8/id', :identifier => 'https://www.google.com/accounts/o8/id',
require: 'omniauth-openid' :require => 'omniauth-openid'
provider :open_id, provider :open_id,
store: OpenID::Store::Redis.new($redis), :store => OpenID::Store::Redis.new($redis),
name: 'yahoo', :name => 'yahoo',
identifier: 'https://me.yahoo.com', :identifier => 'https://me.yahoo.com',
require: 'omniauth-openid' :require => 'omniauth-openid'
# lambda is required for proper multisite support,
# without it subdomains will not function correctly
provider :facebook, provider :facebook,
SiteSetting.facebook_app_id, :setup => lambda { |env|
SiteSetting.facebook_app_secret, strategy = env['omniauth.strategy']
scope: "email" strategy.options[:client_id] = SiteSetting.facebook_app_id
strategy.options[:client_secret] = SiteSetting.facebook_app_secret
},
:scope => "email"
provider :twitter, provider :twitter,
SiteSetting.twitter_consumer_key, :setup => lambda { |env|
SiteSetting.twitter_consumer_secret strategy = env['omniauth.strategy']
strategy.options[:consumer_key] = SiteSetting.twitter_consumer_key
strategy.options[:consumer_secret] = SiteSetting.twitter_consumer_secret
}
provider :github, provider :github,
SiteSetting.github_client_id, :setup => lambda { |env|
SiteSetting.github_client_secret strategy = env['omniauth.strategy']
strategy.options[:client_id] = SiteSetting.github_client_id
strategy.options[:client_secret] = SiteSetting.github_client_secret
}
provider :browser_id, provider :browser_id,
name: 'persona' :name => 'persona'
end end