Github SSO added
This commit is contained in:
parent
65723d3063
commit
b24abd7328
6 changed files with 23 additions and 8 deletions
3
Gemfile
3
Gemfile
|
|
@ -119,6 +119,5 @@ gem "sprockets"
|
||||||
gem 'omniauth'
|
gem 'omniauth'
|
||||||
gem 'omniauth-amazon'
|
gem 'omniauth-amazon'
|
||||||
gem 'omniauth-google-oauth2'
|
gem 'omniauth-google-oauth2'
|
||||||
# gem 'omniauth-github'
|
gem 'omniauth-github'
|
||||||
# gem 'omniauth-twitter'
|
|
||||||
gem 'omniauth-openid'
|
gem 'omniauth-openid'
|
||||||
|
|
|
||||||
|
|
@ -173,6 +173,9 @@ GEM
|
||||||
omniauth-amazon (1.0.1)
|
omniauth-amazon (1.0.1)
|
||||||
omniauth (~> 1.0)
|
omniauth (~> 1.0)
|
||||||
omniauth-oauth2 (~> 1.1)
|
omniauth-oauth2 (~> 1.1)
|
||||||
|
omniauth-github (1.2.3)
|
||||||
|
omniauth (~> 1.5)
|
||||||
|
omniauth-oauth2 (>= 1.4.0, < 2.0)
|
||||||
omniauth-google-oauth2 (0.4.1)
|
omniauth-google-oauth2 (0.4.1)
|
||||||
jwt (~> 1.5.2)
|
jwt (~> 1.5.2)
|
||||||
multi_json (~> 1.3)
|
multi_json (~> 1.3)
|
||||||
|
|
@ -330,6 +333,7 @@ DEPENDENCIES
|
||||||
minitest-reporters
|
minitest-reporters
|
||||||
omniauth
|
omniauth
|
||||||
omniauth-amazon
|
omniauth-amazon
|
||||||
|
omniauth-github
|
||||||
omniauth-google-oauth2
|
omniauth-google-oauth2
|
||||||
omniauth-openid
|
omniauth-openid
|
||||||
paperclip
|
paperclip
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,17 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
||||||
login_via 'Amazon'
|
login_via 'Amazon'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def github
|
||||||
|
login_via 'Github'
|
||||||
|
end
|
||||||
|
|
||||||
|
def failure
|
||||||
|
redirect_to root_path
|
||||||
|
end
|
||||||
|
|
||||||
def login_via(provider_name)
|
def login_via(provider_name)
|
||||||
|
# TODO: log
|
||||||
|
|
||||||
# You need to implement the method below in your model (e.g. app/models/user.rb)
|
# You need to implement the method below in your model (e.g. app/models/user.rb)
|
||||||
@user = User.from_omniauth(request.env["omniauth.auth"])
|
@user = User.from_omniauth(request.env["omniauth.auth"])
|
||||||
|
|
||||||
|
|
@ -31,8 +41,4 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def failure
|
|
||||||
redirect_to root_path
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,8 @@ class User < ApplicationRecord
|
||||||
:launchpad,
|
:launchpad,
|
||||||
:stackexchange,
|
:stackexchange,
|
||||||
:google_oauth2,
|
:google_oauth2,
|
||||||
:amazon
|
:amazon,
|
||||||
|
:github
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@
|
||||||
= link_to "Sign in with StackExchange", user_stackexchange_omniauth_authorize_path
|
= link_to "Sign in with StackExchange", user_stackexchange_omniauth_authorize_path
|
||||||
= link_to "Sign in with Google", user_google_oauth2_omniauth_authorize_path
|
= link_to "Sign in with Google", user_google_oauth2_omniauth_authorize_path
|
||||||
= link_to "Sign in with Amazon", user_amazon_omniauth_authorize_path
|
= link_to "Sign in with Amazon", user_amazon_omniauth_authorize_path
|
||||||
|
= link_to "Sign in with Github", user_github_omniauth_authorize_path
|
||||||
|
|
||||||
/ div
|
/ div
|
||||||
/ = link_to image_tag('/images/sso/google.png'), user_google_oauth2_omniauth_authorize_path
|
/ = link_to image_tag('/images/sso/google.png'), user_google_oauth2_omniauth_authorize_path
|
||||||
|
|
|
||||||
|
|
@ -282,6 +282,10 @@ Devise.setup do |config|
|
||||||
config.omniauth :open_id, name: :launchpad, identifier: 'https://login.ubuntu.com', :client_options => {:ssl => {:ca_path => '/etc/ssl/certs'}}
|
config.omniauth :open_id, name: :launchpad, identifier: 'https://login.ubuntu.com', :client_options => {:ssl => {:ca_path => '/etc/ssl/certs'}}
|
||||||
|
|
||||||
config.omniauth :amazon, ENV['AMAZON_CLIENT_ID'], ENV['AMAZON_CLIENT_SECRET'], :client_options => {:ssl => {:ca_path => '/etc/ssl/certs'}}
|
config.omniauth :amazon, ENV['AMAZON_CLIENT_ID'], ENV['AMAZON_CLIENT_SECRET'], :client_options => {:ssl => {:ca_path => '/etc/ssl/certs'}}
|
||||||
|
{:ssl => {:ca_path => '/etc/ssl/certs'}}
|
||||||
|
|
||||||
# client_options: {ssl: {ca_path: '/etc/ssl/certs'}}
|
config.omniauth :github, ENV['GITHUB_CLIENT_ID'], ENV['GITHUB_CLIENT_SECRET'],
|
||||||
|
client_options: {
|
||||||
|
ssl: { ca_path: '/etc/ssl/certs' }
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue