1 require "openid/fetchers"
4 CA_BUNDLES = ["/etc/ssl/certs/ca-certificates.crt", "/etc/pki/tls/cert.pem"].freeze
6 OpenID.fetcher.ca_file = CA_BUNDLES.find { |f| File.exist?(f) }
7 OpenID::Util.logger = Rails.logger
9 OmniAuth.config.logger = Rails.logger
10 OmniAuth.config.failure_raise_out_environments = []
12 if defined?(MEMCACHE_SERVERS)
13 require "openid/store/memcache"
15 openid_store = OpenID::Store::Memcache.new(Dalli::Client.new(MEMCACHE_SERVERS, :namespace => "rails"))
17 require "openid/store/filesystem"
19 openid_store = OpenID::Store::Filesystem.new(Rails.root.join("tmp", "openids"))
22 openid_options = { :name => "openid", :store => openid_store }
23 google_options = { :name => "google", :scope => "email", :access_type => "online" }
24 facebook_options = { :name => "facebook", :scope => "email" }
25 windowslive_options = { :name => "windowslive", :scope => "wl.signin,wl.emails" }
26 github_options = { :name => "github", :scope => "user:email" }
27 wikipedia_options = { :name => "wikipedia", :client_options => { :site => "https://meta.wikimedia.org" } }
29 google_options[:openid_realm] = GOOGLE_OPENID_REALM if defined?(GOOGLE_OPENID_REALM)
31 Rails.application.config.middleware.use OmniAuth::Builder do
32 provider :openid, openid_options
33 provider :google_oauth2, GOOGLE_AUTH_ID, GOOGLE_AUTH_SECRET, google_options if defined?(GOOGLE_AUTH_ID)
34 provider :facebook, FACEBOOK_AUTH_ID, FACEBOOK_AUTH_SECRET, facebook_options if defined?(FACEBOOK_AUTH_ID)
35 provider :windowslive, WINDOWSLIVE_AUTH_ID, WINDOWSLIVE_AUTH_SECRET, windowslive_options if defined?(WINDOWSLIVE_AUTH_ID)
36 provider :github, GITHUB_AUTH_ID, GITHUB_AUTH_SECRET, github_options if defined?(GITHUB_AUTH_ID)
37 provider :mediawiki, WIKIPEDIA_AUTH_ID, WIKIPEDIA_AUTH_SECRET, wikipedia_options if defined?(WIKIPEDIA_AUTH_ID)