]> git.openstreetmap.org Git - rails.git/blob - config/initializers/omniauth.rb
8190a65b96fb63b4c30773a0f5b5b8aa85e86ce1
[rails.git] / config / initializers / omniauth.rb
1 require "openid/fetchers"
2
3 CA_BUNDLES = ["/etc/ssl/certs/ca-certificates.crt", "/etc/pki/tls/cert.pem"]
4
5 OpenID.fetcher.ca_file = CA_BUNDLES.find { |f| File.exist?(f) }
6
7 OmniAuth.config.logger = Rails.logger
8 OmniAuth.config.failure_raise_out_environments = []
9
10 if defined?(MEMCACHE_SERVERS)
11   require "openid/store/memcache"
12
13   openid_store = OpenID::Store::Memcache.new(Dalli::Client.new(MEMCACHE_SERVERS, :namespace => "rails"))
14 else
15   require "openid/store/filesystem"
16
17   openid_store = OpenID::Store::Filesystem.new(Rails.root.join("tmp/openids"))
18 end
19
20 Rails.application.config.middleware.use OmniAuth::Builder do
21   provider :openid, :name => "openid", :store => openid_store
22 end
23
24 # Pending fix for: https://github.com/intridea/omniauth/pull/795
25 module OmniAuth
26   module Strategy
27     def mock_callback_call_with_origin
28       @env["omniauth.origin"] = session["omniauth.origin"]
29
30       mock_callback_call_without_origin
31     end
32
33     alias_method_chain :mock_callback_call, :origin
34   end
35 end