Add support for Google OAuth2 authentication

This replaces OpenID authentication, which is going away soon, but
provides an upgrade path where we can migrate users that already have
a Google OpenID setup to the new system transparently.
This commit is contained in:
Tom Hughes 2015-02-28 15:56:41 +00:00
parent 7ed50894e2
commit eeb9866d50
10 changed files with 51 additions and 12 deletions

View file

@ -19,8 +19,16 @@ else
openid_store = OpenID::Store::Filesystem.new(Rails.root.join("tmp/openids"))
end
openid_options = { :name => "openid", :store => openid_store }
google_options = { :name => "google", :scope => "email", :access_type => "online" }
if defined?(GOOGLE_OPENID_REALM)
google_options[:openid_realm] = GOOGLE_OPENID_REALM
end
Rails.application.config.middleware.use OmniAuth::Builder do
provider :openid, :name => "openid", :store => openid_store
provider :openid, openid_options
provider :google_oauth2, GOOGLE_AUTH_ID, GOOGLE_AUTH_SECRET, google_options if defined?(GOOGLE_AUTH_ID)
end
# Pending fix for: https://github.com/intridea/omniauth/pull/795