SSO using Amazon added
This commit is contained in:
parent
194a990656
commit
909be1c8ae
5 changed files with 40 additions and 11 deletions
|
|
@ -23,6 +23,16 @@ The private key is:
|
|||
|
||||
## Amazon
|
||||
|
||||
Client ID:
|
||||
|
||||
amzn1.application-oa2-client.78d832919fc24456b0636762cf18efd9
|
||||
|
||||
Client Secret:
|
||||
|
||||
8c495d0940ca4100313c03e93b8b4240eef256d2fdbe672718506f29f5a20f61
|
||||
|
||||
Available login buttons: https://login.amazon.com/button-guide
|
||||
|
||||
## launchpad
|
||||
|
||||
## Github
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
||||
|
||||
def passthru
|
||||
raise
|
||||
send(params[:provider]) if providers.include?(params[:provider])
|
||||
end
|
||||
# def passthru
|
||||
# raise
|
||||
# send(params[:provider]) if providers.include?(params[:provider])
|
||||
# end
|
||||
|
||||
def launchpad
|
||||
# You need to implement the method below in your model (e.g. app/models/user.rb)
|
||||
|
|
@ -32,13 +32,26 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
|||
end
|
||||
end
|
||||
|
||||
def failure
|
||||
redirect_to root_path
|
||||
def amazon
|
||||
# You need to implement the method below in your model (e.g. app/models/user.rb)
|
||||
@user = User.from_omniauth(request.env["omniauth.auth"])
|
||||
|
||||
if @user.persisted?
|
||||
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Amazon"
|
||||
sign_in_and_redirect @user, :event => :authentication
|
||||
else
|
||||
# session["devise.google_data"] = request.env["omniauth.auth"].except(:extra) #Removing extra as it can overflow some session stores
|
||||
redirect_to new_user_session_url, alert: @user.errors.full_messages.join("\n")
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# def failure
|
||||
# redirect_to root_path
|
||||
# end
|
||||
|
||||
def providers
|
||||
["twitter", "google_oauth2"]
|
||||
end
|
||||
# private
|
||||
#
|
||||
# def providers
|
||||
# ["twitter", "google_oauth2", "launchpad", "amazon"]
|
||||
# end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class User < ApplicationRecord
|
|||
# :validatable,
|
||||
:timeoutable,
|
||||
# :lockable,
|
||||
:omniauthable, :omniauth_providers => [:google_oauth2, :launchpad]
|
||||
:omniauthable, :omniauth_providers => [:google_oauth2, :launchpad, :amazon]
|
||||
# :omniauthable, :omniauth_providers => [:launchpad, :google]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -36,4 +36,7 @@
|
|||
|
||||
/ = link_to "Sign in with Launchpad", user_launchpad_omniauth_authorize_path
|
||||
= link_to "Sign in with Google", user_google_oauth2_omniauth_authorize_path
|
||||
|
||||
= link_to "Sign in with Launchpad", user_launchpad_omniauth_authorize_path
|
||||
|
||||
= link_to "Sign in with Amazon", user_amazon_omniauth_authorize_path
|
||||
|
|
|
|||
|
|
@ -275,8 +275,11 @@ Devise.setup do |config|
|
|||
|
||||
# config.omniauth :launchpad, 'debshots'
|
||||
config.omniauth :google_oauth2, '398593918966-0fpmit0pb6ptio1ndsie5dfcnqhei63l.apps.googleusercontent.com', 'uRQq_dLs1kx7l5sYIyEyPVRc', :client_options => {:ssl => {:ca_path => '/etc/ssl/certs'}}
|
||||
|
||||
config.omniauth :launchpad, 'Debian Screenshots', :client_options => {:ssl => {:ca_path => '/etc/ssl/certs'}}
|
||||
|
||||
config.omniauth :amazon, 'amzn1.application-oa2-client.78d832919fc24456b0636762cf18efd9', '8c495d0940ca4100313c03e93b8b4240eef256d2fdbe672718506f29f5a20f61', :client_options => {:ssl => {:ca_path => '/etc/ssl/certs'}}
|
||||
|
||||
end
|
||||
|
||||
# OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue