From aacc7f4baa94eb4b54d29ed42e236b035b2c40c0 Mon Sep 17 00:00:00 2001 From: Nicolae Claudius Date: Thu, 16 Jan 2014 09:16:25 +0200 Subject: [PATCH] change from google_apps to google_oauth2 --- Gemfile | 2 +- Gemfile.lock | 30 +++++++++++-------- .../users/omniauth_callbacks_controller.rb | 6 ++-- app/helpers/users/authentications_helper.rb | 2 +- app/models/user.rb | 2 +- app/views/users/registrations/_new.html.erb | 2 +- app/views/users/sessions/new.html.erb | 2 +- config/initializers/devise.rb | 6 +--- config/settings.sample.yml | 3 ++ 9 files changed, 29 insertions(+), 26 deletions(-) diff --git a/Gemfile b/Gemfile index 24b8f92..a1dc6c8 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ gem 'rails', '4.0.2' gem 'mysql2', '~> 0.3.13' gem 'devise', '~> 3.2.2' gem 'omniauth', '~> 1.1.4' -gem 'omniauth-google-apps', '~> 0.1.0' +gem 'omniauth-google-oauth2', '~> 0.2.2' gem 'cancan', '= 1.6.7' gem 'squeel', '~> 1.1.0' gem 'sentient_model', '~> 1.0.4' diff --git a/Gemfile.lock b/Gemfile.lock index c1b247c..7f0122e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -122,6 +122,8 @@ GEM railties (>= 3.0.0) faker (1.2.0) i18n (~> 0.5) + faraday (0.8.9) + multipart-post (~> 1.2.0) font-awesome-rails (4.0.3.0) railties (>= 3.2, < 5.0) fssm (0.2.10) @@ -129,6 +131,7 @@ GEM tilt hashie (2.0.5) hike (1.2.3) + httpauth (0.2.0) i18n (0.6.9) jquery-rails (3.0.4) railties (>= 3.0, < 5.0) @@ -136,6 +139,8 @@ GEM jquery-ui-rails (4.1.1) railties (>= 3.1.0) json (1.8.1) + jwt (0.1.10) + multi_json (>= 1.5) kaminari (0.15.0) actionpack (>= 3.0.0) activesupport (>= 3.0.0) @@ -155,6 +160,7 @@ GEM mini_portile (0.5.2) minitest (4.7.5) multi_json (1.8.2) + multipart-post (1.2.0) mysql2 (0.3.14) nested_form (0.3.2) nilify_blanks (1.0.3) @@ -163,19 +169,23 @@ GEM nokogiri (1.6.1) mini_portile (~> 0.5.0) nprogress-rails (0.1.2.3) + oauth2 (0.8.1) + faraday (~> 0.8) + httpauth (~> 0.1) + jwt (~> 0.1.4) + multi_json (~> 1.0) + rack (~> 1.2) oily_png (1.1.0) chunky_png (~> 1.2.7) omniauth (1.1.4) hashie (>= 1.2, < 3) rack - omniauth-google-apps (0.1.0) + omniauth-google-oauth2 (0.2.2) omniauth (~> 1.0) - omniauth-openid (~> 1.0) - ruby-openid (~> 2.3.0) - ruby-openid-apps-discovery (~> 1.2.0) - omniauth-openid (1.0.1) + omniauth-oauth2 + omniauth-oauth2 (1.1.1) + oauth2 (~> 0.8.0) omniauth (~> 1.0) - rack-openid (~> 1.3.1) orm_adapter (0.5.0) polyamorous (0.6.4) activerecord (>= 3.0) @@ -183,9 +193,6 @@ GEM quiet_assets (1.0.2) railties (>= 3.1, < 5.0) rack (1.5.2) - rack-openid (1.3.1) - rack (>= 1.1.0) - ruby-openid (>= 2.1.8) rack-pjax (0.7.0) nokogiri (~> 1.5) rack (~> 1.3) @@ -238,9 +245,6 @@ GEM rspec-core (~> 2.14.0) rspec-expectations (~> 2.14.0) rspec-mocks (~> 2.14.0) - ruby-openid (2.3.0) - ruby-openid-apps-discovery (1.2.0) - ruby-openid (>= 2.1.7) safe_yaml (0.9.7) sass (3.2.13) sass-rails (4.0.1) @@ -331,7 +335,7 @@ DEPENDENCIES nprogress-rails (~> 0.1.2.2) oily_png (~> 1.1.0) omniauth (~> 1.1.4) - omniauth-google-apps (~> 0.1.0) + omniauth-google-oauth2 (~> 0.2.2) quiet_assets (~> 1.0.1) rails (= 4.0.2) rails-settings-cached (~> 0.3.1) diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 050e463..7f0efdd 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -1,7 +1,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController - def google_apps - oauthorize 'google_apps' + def google_oauth2 + oauthorize 'google_oauth2' end protected @@ -11,7 +11,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController @user = find_or_create_user(provider) return redirect_to(:back) unless @user && @user.active_for_authentication? flash[:notice] = I18n.t "devise.omniauth_callbacks.success", kind: provider.camelcase - session["devise.google_apps_data"] = env["omniauth.auth"] + session["devise.google_data"] = env["omniauth.auth"] @user.remember_me! if session.delete(:user_remember_me) == "1" sign_in_and_redirect @user, event: :authentication end diff --git a/app/helpers/users/authentications_helper.rb b/app/helpers/users/authentications_helper.rb index 54788a8..f133078 100644 --- a/app/helpers/users/authentications_helper.rb +++ b/app/helpers/users/authentications_helper.rb @@ -1,7 +1,7 @@ module Users::AuthenticationsHelper def authentication_provider_column(record, column) case record.provider - when 'google_apps' + when 'google_oauth2' ret = <<-DOC Google diff --git a/app/models/user.rb b/app/models/user.rb index 8f9868c..e8f8b1a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -14,7 +14,7 @@ class User < ActiveRecord::Base :confirmable, :lockable, :omniauthable, - :omniauth_providers => [:google_apps] + :omniauth_providers => [:google_oauth2] validates :full_name, :presence => true diff --git a/app/views/users/registrations/_new.html.erb b/app/views/users/registrations/_new.html.erb index 8e818bb..bb88ce2 100644 --- a/app/views/users/registrations/_new.html.erb +++ b/app/views/users/registrations/_new.html.erb @@ -7,7 +7,7 @@ %>

- <%= link_to user_omniauth_authorize_path(:google_apps), + <%= link_to user_omniauth_authorize_path(:google_oauth2), class: 'btn btn-block btn-social btn-google-plus', 'data-no-turbolink' => true do %> Sign up with Google diff --git a/app/views/users/sessions/new.html.erb b/app/views/users/sessions/new.html.erb index 5d2dbd8..7380043 100644 --- a/app/views/users/sessions/new.html.erb +++ b/app/views/users/sessions/new.html.erb @@ -4,7 +4,7 @@

- <%= link_to user_omniauth_authorize_path(:google_apps), + <%= link_to user_omniauth_authorize_path(:google_oauth2), class: 'btn btn-block btn-social btn-google-plus', 'data-no-turbolink' => true do %> Sign in with Google diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index aaae2c8..c361986 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -1,5 +1,3 @@ -require 'openid/store/filesystem' - # Use this hook to configure devise mailer, warden hooks and so forth. The first # four configuration values can also be set straight in your models. Devise.setup do |config| @@ -198,9 +196,7 @@ Devise.setup do |config| # config.omniauth :open_id, name: 'user', # identifier: 'https://www.google.com/accounts/o8/site-xrds?hd=' + Settings.domain, # store: OpenID::Store::Filesystem.new('/tmp') - config.omniauth :google_apps, - store: OpenID::Store::Filesystem.new('/tmp'), - domain: 'gmail.com' + config.omniauth :google_oauth2, Settings.google_key, Settings.google_secret # ==> Warden configuration # If you want to use other strategies, that are not supported by Devise, or diff --git a/config/settings.sample.yml b/config/settings.sample.yml index d37a99e..ed869e4 100644 --- a/config/settings.sample.yml +++ b/config/settings.sample.yml @@ -33,3 +33,6 @@ resolv: honeypot: userid support_mail: "support@entrydns.net" news_link: "http://twitter.com/#!/entrydns" + +google_key: 105547277286.apps.googleusercontent.com +google_secret: 7cIdW07UrWUmeb8QFYV4L63k