adds Google OAuth2 support

This commit is contained in:
David Gil
2015-08-25 14:15:24 +02:00
parent de15bbe911
commit 59aede5b00
9 changed files with 20 additions and 3 deletions

View File

@@ -24,7 +24,7 @@ gem 'devise'
gem 'omniauth' gem 'omniauth'
gem 'omniauth-twitter' gem 'omniauth-twitter'
gem 'omniauth-facebook' gem 'omniauth-facebook'
# gem 'omniauth-google-oauth2' gem 'omniauth-google-oauth2'
gem 'kaminari' gem 'kaminari'
gem 'acts_as_commentable_with_threading' gem 'acts_as_commentable_with_threading'

View File

@@ -213,6 +213,9 @@ GEM
rack (~> 1.0) rack (~> 1.0)
omniauth-facebook (2.0.1) omniauth-facebook (2.0.1)
omniauth-oauth2 (~> 1.2) omniauth-oauth2 (~> 1.2)
omniauth-google-oauth2 (0.2.6)
omniauth (> 1.0)
omniauth-oauth2 (~> 1.1)
omniauth-oauth (1.1.0) omniauth-oauth (1.1.0)
oauth oauth
omniauth (~> 1.0) omniauth (~> 1.0)
@@ -391,6 +394,7 @@ DEPENDENCIES
letter_opener_web (~> 1.3.0) letter_opener_web (~> 1.3.0)
omniauth omniauth
omniauth-facebook omniauth-facebook
omniauth-google-oauth2
omniauth-twitter omniauth-twitter
paranoia paranoia
pg pg

View File

@@ -15,8 +15,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
} }
end end
# [:twitter, :facebook, :google_oauth2].each do |provider| [:twitter, :facebook, :google_oauth2].each do |provider|
[:twitter, :facebook].each do |provider|
provides_callback_for provider provides_callback_for provider
end end

View File

@@ -2,5 +2,6 @@
<%= link_to t("omniauth.twitter.sign_in"), user_omniauth_authorize_path(:twitter), class: 'button radius expand' %> <%= link_to t("omniauth.twitter.sign_in"), user_omniauth_authorize_path(:twitter), class: 'button radius expand' %>
<%= link_to t("omniauth.facebook.sign_in"), user_omniauth_authorize_path(:facebook), class: 'button radius expand' %> <%= link_to t("omniauth.facebook.sign_in"), user_omniauth_authorize_path(:facebook), class: 'button radius expand' %>
<%= link_to t("omniauth.google_oauth2.sign_in"), user_omniauth_authorize_path(:google_oauth2), class: 'button radius expand' %>
<hr/> <hr/>

View File

@@ -6,4 +6,6 @@
twitter_secret: <%= ENV["TWITTER_SECRET"] %> twitter_secret: <%= ENV["TWITTER_SECRET"] %>
facebook_key: <%= ENV["FACEBOOK_KEY"] %> facebook_key: <%= ENV["FACEBOOK_KEY"] %>
facebook_secret: <%= ENV["FACEBOOK_SECRET"] %> facebook_secret: <%= ENV["FACEBOOK_SECRET"] %>
google_oauth2_key: <%= ENV["GOOGLE_KEY"] %>
google_oauth2_secret: <%= ENV["GOOGLE_SECRET"] %>
server_name: <%= fetch(:server_name) %> server_name: <%= fetch(:server_name) %>

View File

@@ -241,6 +241,7 @@ Devise.setup do |config|
# config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo' # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
config.omniauth :twitter, Rails.application.secrets.twitter_key, Rails.application.secrets.twitter_secret config.omniauth :twitter, Rails.application.secrets.twitter_key, Rails.application.secrets.twitter_secret
config.omniauth :facebook, Rails.application.secrets.facebook_key, Rails.application.secrets.facebook_secret config.omniauth :facebook, Rails.application.secrets.facebook_key, Rails.application.secrets.facebook_secret
config.omniauth :google_oauth2, Rails.application.secrets.google_oauth2_key, Rails.application.secrets.google_oauth2_secret
# ==> Warden configuration # ==> Warden configuration
# If you want to use other strategies, that are not supported by Devise, or # If you want to use other strategies, that are not supported by Devise, or

View File

@@ -155,3 +155,5 @@ en:
sign_in: Sign in with Twitter sign_in: Sign in with Twitter
facebook: facebook:
sign_in: Sign in with Facebook sign_in: Sign in with Facebook
google_oauth2:
sign_in: Sign in with Google

View File

@@ -155,3 +155,5 @@ es:
sign_in: Entra con Twitter sign_in: Entra con Twitter
facebook: facebook:
sign_in: Entra con Facebook sign_in: Entra con Facebook
google_oauth2:
sign_in: Entra con Google

View File

@@ -18,6 +18,8 @@ development:
twitter_secret: BBBB twitter_secret: BBBB
facebook_key: AAAA facebook_key: AAAA
facebook_secret: BBBB facebook_secret: BBBB
google_oauth2_key: AAAA
google_oauth2_secret: BBBB
<<: *default <<: *default
test: test:
@@ -26,6 +28,8 @@ test:
twitter_secret: BBBB twitter_secret: BBBB
facebook_key: AAAA facebook_key: AAAA
facebook_secret: BBBB facebook_secret: BBBB
google_oauth2_key: AAAA
google_oauth2_secret: BBBB
<<: *default <<: *default
production: production:
@@ -34,4 +38,6 @@ production:
twitter_secret: <%= ENV["TWITTER_SECRET"] %> twitter_secret: <%= ENV["TWITTER_SECRET"] %>
facebook_key: <%= ENV["FACEBOOK_KEY"] %> facebook_key: <%= ENV["FACEBOOK_KEY"] %>
facebook_secret: <%= ENV["FACEBOOK_SECRET"] %> facebook_secret: <%= ENV["FACEBOOK_SECRET"] %>
google_oauth2_key: <%= ENV["GOOGLE_KEY"] %>
google_oauth2_secret: <%= ENV["GOOGLE_SECRET"] %>
<<: *default <<: *default