Salsa login works
This commit is contained in:
parent
b2ed771663
commit
bc507cbe39
6 changed files with 84 additions and 51 deletions
|
|
@ -3,29 +3,33 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
|||
# Workaround for https://github.com/plataformatec/devise/issues/2432
|
||||
# skip_before_filter :verify_authenticity_token
|
||||
|
||||
def launchpad
|
||||
login_via 'Launchpad'
|
||||
def salsa
|
||||
login_via 'salsa.debian.org'
|
||||
end
|
||||
|
||||
def stackexchange
|
||||
login_via 'StackExchange'
|
||||
end
|
||||
# def launchpad
|
||||
# login_via 'Launchpad'
|
||||
# end
|
||||
|
||||
def google_oauth2
|
||||
login_via 'Google'
|
||||
end
|
||||
# def stackexchange
|
||||
# login_via 'StackExchange'
|
||||
# end
|
||||
|
||||
def amazon
|
||||
login_via 'Amazon'
|
||||
end
|
||||
# def google_oauth2
|
||||
# login_via 'Google'
|
||||
# end
|
||||
|
||||
def github
|
||||
login_via 'Github'
|
||||
end
|
||||
# def amazon
|
||||
# login_via 'Amazon'
|
||||
# end
|
||||
|
||||
def failure
|
||||
redirect_to root_path
|
||||
end
|
||||
# def github
|
||||
# login_via 'Github'
|
||||
# end
|
||||
|
||||
# def failure
|
||||
# redirect_to root_path
|
||||
# end
|
||||
|
||||
def login_via(provider_name)
|
||||
# TODO: log
|
||||
|
|
|
|||
|
|
@ -11,29 +11,30 @@ class User < ApplicationRecord
|
|||
# :validatable,
|
||||
:timeoutable,
|
||||
# :lockable,
|
||||
:omniauthable, :omniauth_providers => [
|
||||
:launchpad,
|
||||
:stackexchange,
|
||||
:google_oauth2,
|
||||
:amazon,
|
||||
:github
|
||||
:omniauthable, omniauth_providers: [
|
||||
:salsa,
|
||||
# :launchpad,
|
||||
# :stackexchange,
|
||||
# :google_oauth2,
|
||||
# :amazon,
|
||||
# :github
|
||||
]
|
||||
|
||||
# Return a human-friendly string describing the user's SSO provider
|
||||
def pretty_provider
|
||||
case self.provider
|
||||
when 'launchpad'
|
||||
'Ubuntu One/Launchpad'
|
||||
when 'stackexchange'
|
||||
'StackExchange'
|
||||
when 'google_oauth2'
|
||||
'Google'
|
||||
when 'amazon'
|
||||
'Amazon'
|
||||
when 'github'
|
||||
'GitHub'
|
||||
when 'debian-sso'
|
||||
'Debian single-sign-on'
|
||||
# when 'launchpad'
|
||||
# 'Ubuntu One/Launchpad'
|
||||
# when 'stackexchange'
|
||||
# 'StackExchange'
|
||||
# when 'google_oauth2'
|
||||
# 'Google'
|
||||
# when 'amazon'
|
||||
# 'Amazon'
|
||||
# when 'github'
|
||||
# 'GitHub'
|
||||
when 'salsa'
|
||||
'salsa.debian.org'
|
||||
else
|
||||
'local authentication'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -28,9 +28,12 @@
|
|||
/ a href='https://sso.debian.org/' Debian SSO
|
||||
/ ' installed in your browser.
|
||||
|
||||
/ .grid-container
|
||||
/ .text-center
|
||||
|
||||
.grid-container
|
||||
.text-center
|
||||
|
||||
p
|
||||
= link_to (fa_icon 'login', text: 'Login with Debian'), user_salsa_omniauth_authorize_path, class: 'button primary large', method: :post
|
||||
|
||||
/ // Alternative way to display buttons without images. (Amazon wants their own button though.)
|
||||
/ / p
|
||||
/ / = link_to (fa_icon 'google', text: '- Login with Google'), user_google_oauth2_omniauth_authorize_path, class: 'button secondary large'
|
||||
|
|
|
|||
|
|
@ -30,3 +30,5 @@
|
|||
- if current_user.is_admin?
|
||||
h2 Admin
|
||||
p Apparently you are an administrator. Be careful with that thing!
|
||||
|
||||
tt = current_user.inspect
|
||||
|
|
|
|||
|
|
@ -286,22 +286,44 @@ Devise.setup do |config|
|
|||
# config.omniauth_path_prefix = '/my_engine/users/auth'
|
||||
|
||||
# config.omniauth :launchpad, 'debshots'
|
||||
config.omniauth :google_oauth2, ENV["GOOGLE_CLIENT_ID"], ENV["GOOGLE_CLIENT_SECRET"],
|
||||
:client_options => {:ssl => {:ca_path => '/etc/ssl/certs'}}
|
||||
|
||||
config.omniauth :open_id, name: :stackexchange, identifier: 'https://openid.stackexchange.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 :github, ENV['GITHUB_CLIENT_ID'], ENV['GITHUB_CLIENT_SECRET'],
|
||||
# Hint: https://salsa.debian.org/.well-known/openid-configuration
|
||||
# Configuration: https://github.com/m0n9oose/omniauth_openid_connect
|
||||
config.omniauth :openid_connect, {
|
||||
name: :salsa,
|
||||
scope: [:openid, :email, :profile],
|
||||
discovery: true,
|
||||
issuer: "https://salsa.debian.org",
|
||||
client_options: {
|
||||
ssl: { ca_path: '/etc/ssl/certs' }
|
||||
port: 443,
|
||||
scheme: "https",
|
||||
host: "salsa.debian.org",
|
||||
identifier: ENV['GITLAB_OAUTH_KEY'],
|
||||
secret: ENV['GITLAB_OAUTH_SECRET'],
|
||||
redirect_uri: "http://localhost:3000/users/auth/salsa/callback",
|
||||
ssl: { ca_path: '/etc/ssl/certs'}
|
||||
}
|
||||
}
|
||||
OpenIDConnect.logger = Rails.logger
|
||||
OmniAuth.config.logger = Rails.logger if Rails.env.development?
|
||||
|
||||
# config.omniauth :google_oauth2, ENV["GOOGLE_CLIENT_ID"], ENV["GOOGLE_CLIENT_SECRET"],
|
||||
# :client_options => {:ssl => {:ca_path => '/etc/ssl/certs'}}
|
||||
|
||||
# config.omniauth :open_id, name: :stackexchange, identifier: 'https://openid.stackexchange.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 :github, ENV['GITHUB_CLIENT_ID'], ENV['GITHUB_CLIENT_SECRET'],
|
||||
# client_options: {
|
||||
# ssl: { ca_path: '/etc/ssl/certs' }
|
||||
# }
|
||||
|
||||
# ==> Turbolinks configuration
|
||||
# If your app is using Turbolinks, Turbolinks::Controller needs to be included to make redirection work correctly:
|
||||
#
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ Rails.application.routes.draw do
|
|||
|
||||
get 'admin/integration'
|
||||
|
||||
# https://www.rubydoc.info/github/plataformatec/devise/ActionDispatch%2FRouting%2FMapper:devise_for
|
||||
devise_for :users, controllers: {
|
||||
# registrations: "users/registrations",
|
||||
# passwords: "users/passwords",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue