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