From bf6b09d9f43f47c822c4450e708bc9bc04a98439 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Thu, 24 Jul 2014 23:18:57 +0300 Subject: [PATCH] add github for openid login --- Gemfile | 1 + Gemfile.lock | 4 ++++ app/models/user.rb | 2 +- config/initializers/devise.rb | 1 + config/secrets.yml.example | 6 +++++- 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 01c8a4f0..9c3eda3f 100644 --- a/Gemfile +++ b/Gemfile @@ -19,6 +19,7 @@ gem 'omniauth' gem 'omniauth-facebook' gem 'omniauth-openid' gem 'omniauth-google-oauth2' +gem 'omniauth-github' # Use cancancan as authorization framework gem 'cancancan' diff --git a/Gemfile.lock b/Gemfile.lock index 5c4b58ac..bf7fb167 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -210,6 +210,9 @@ GEM rack (~> 1.0) omniauth-facebook (1.6.0) omniauth-oauth2 (~> 1.1) + omniauth-github (1.1.2) + omniauth (~> 1.0) + omniauth-oauth2 (~> 1.1) omniauth-google-oauth2 (0.2.4) omniauth (~> 1.0) omniauth-oauth2 (~> 1.1) @@ -429,6 +432,7 @@ DEPENDENCIES mysql2 omniauth omniauth-facebook + omniauth-github omniauth-google-oauth2 omniauth-openid paper_trail diff --git a/app/models/user.rb b/app/models/user.rb index 88cd34f7..498cb68c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -7,7 +7,7 @@ class User < ActiveRecord::Base # :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :confirmable, - :omniauthable, omniauth_providers: [:suse, :google, :facebook] + :omniauthable, omniauth_providers: [:suse, :google, :facebook, :github] has_and_belongs_to_many :roles has_many :openids diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 1caa0d05..7b9ecaa4 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -14,6 +14,7 @@ Devise.setup do |config| name: 'google', scope: 'email' config.omniauth :facebook, Rails.application.secrets.facebook_key, Rails.application.secrets.facebook_secret + config.omniauth :github, Rails.application.secrets.github_key, Rails.application.secrets.github_secret # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, diff --git a/config/secrets.yml.example b/config/secrets.yml.example index f6e1c7ff..9bc47979 100644 --- a/config/secrets.yml.example +++ b/config/secrets.yml.example @@ -45,8 +45,12 @@ production: # For example: #suse_key: 'sample data' #suse_secret: 'sample data' - suse_key: '' suse_secret: '' + + # Register your application with GitHub from https://github.com/settings/applications + github_key: '7e38bdc9408721600e2c' + github_secret: '0290d60c27b1f0b9e88d73551862f6e0136976ba' + # If you add more providers that do not require a key, you still have to create the 2 variables with sample data