Skip to content

Commit

Permalink
correct multisite functionality for omniauth
Browse files Browse the repository at this point in the history
  • Loading branch information
SamSaffron committed Mar 25, 2013
1 parent deb603f commit 988a712
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ end

group :development do
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 'pry-rails'
end
Expand Down
43 changes: 27 additions & 16 deletions config/initializers/omniauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,42 @@
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'
: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'
:store => OpenID::Store::Redis.new($redis),
:name => 'yahoo',
:identifier => 'https://me.yahoo.com',
:require => 'omniauth-openid'

# lambda is required for proper multisite support,
# without it subdomains will not function correctly
provider :facebook,
SiteSetting.facebook_app_id,
SiteSetting.facebook_app_secret,
scope: "email"
: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,
SiteSetting.twitter_consumer_key,
SiteSetting.twitter_consumer_secret
: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,
SiteSetting.github_client_id,
SiteSetting.github_client_secret
:setup => lambda { |env|
strategy = env['omniauth.strategy']
strategy.options[:client_id] = SiteSetting.github_client_id
strategy.options[:client_secret] = SiteSetting.github_client_secret
}

provider :browser_id,
name: 'persona'
:name => 'persona'

end

0 comments on commit 988a712

Please sign in to comment.