able to handle launcher login with gem

This commit is contained in:
bruckwubete 2018-07-04 14:48:22 -04:00
parent 2bb41977ed
commit 3c11aca1aa
6 changed files with 20 additions and 8 deletions

View File

@ -47,7 +47,6 @@ gem 'bcrypt', '~> 3.1.7'
gem 'omniauth' gem 'omniauth'
gem 'omniauth-twitter' gem 'omniauth-twitter'
gem 'omniauth-google-oauth2' gem 'omniauth-google-oauth2'
gem "omniauth-bn-launcher", git: "https://github.com/blindsidenetworks/omniauth-bn-launcher.git"
# BigBlueButton API wrapper. # BigBlueButton API wrapper.
gem 'bigbluebutton-api-ruby' gem 'bigbluebutton-api-ruby'
@ -65,6 +64,7 @@ gem 'rubocop', require: false
group :production do group :production do
# Use a postgres database in production. # Use a postgres database in production.
gem 'pg', '~> 0.18' gem 'pg', '~> 0.18'
gem "omniauth-bn-launcher", git: "https://github.com/blindsidenetworks/omniauth-bn-launcher.git", branch: "oauth2"
end end
group :development, :test do group :development, :test do

View File

@ -1,9 +1,11 @@
GIT GIT
remote: https://github.com/blindsidenetworks/omniauth-bn-launcher.git remote: https://github.com/blindsidenetworks/omniauth-bn-launcher.git
revision: 52fbc3ff40c64ad5eef51f7e6c0beba2c666356f revision: d93b9fa51f920c733618ec4040c93458ff19951f
branch: oauth2
specs: specs:
omniauth-bn-launcher (0.1.0) omniauth-bn-launcher (0.1.0)
omniauth (~> 1.3, >= 1.3.2) omniauth (~> 1.3, >= 1.3.2)
omniauth-oauth2 (= 1.5.0)
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/

View File

@ -7,7 +7,7 @@ class MainController < ApplicationController
def index def index
if current_user if current_user
# Redirect authenticated users to their room. # Redirect authenticated users to their room.
redirect_to room_path(current_user.room) redirect_to room_path(current_user.main_room)
else else
# Redirect unauthenticated users to root. # Redirect unauthenticated users to root.
#TODO use env? for launcher login endpoint #TODO use env? for launcher login endpoint

View File

@ -67,19 +67,19 @@ class User < ApplicationRecord
end end
def bn_launcher_name(auth) def bn_launcher_name(auth)
auth['user_info']['username'] auth['info']['name']
end end
def bn_launcher_username(auth) def bn_launcher_username(auth)
auth['user_info']['username'] auth['info']['username']
end end
def bn_launcher_email(auth) def bn_launcher_email(auth)
auth['user_info']['email'] auth['info']['email']
end end
def bn_launcher_image(auth) def bn_launcher_image(auth)
"" auth['info']['image']
end end
end end

View File

@ -1,4 +1,9 @@
#!/bin/bash #!/bin/bash
while [ "$RAILS_ENV" = "production" ] && ! curl http://$DB_HOST:5432/ 2>&1 | grep '52'
do
echo "Waiting for postgres to start up ..."
sleep 1
done
bundle exec rake db:create bundle exec rake db:create
bundle exec rake db:migrate bundle exec rake db:migrate

View File

@ -10,8 +10,13 @@ Rails.application.config.omniauth_bn_launcher = (ENV["USE_LOADBALANCED_CONFIGURA
# Setup the Omniauth middleware. # Setup the Omniauth middleware.
Rails.application.config.middleware.use OmniAuth::Builder do Rails.application.config.middleware.use OmniAuth::Builder do
if Rails.env.production?
provider :bn_launcher,
client_id: ENV['BN_LAUNCHER_CLIENT_ID'],
client_secret: ENV['BN_LAUNCHER_CLIENT_SECRET'],
client_options: {site: ENV['BN_LAUNCHER_REDIRECT_URI']}
end
provider :bn_launcher, ENV['LAUNCHER_SECRET'], (ENV['LAUNCHER_RELATIVE_URL_ROOT'] || '' + '/login')
provider :twitter, ENV['TWITTER_ID'], ENV['TWITTER_SECRET'] provider :twitter, ENV['TWITTER_ID'], ENV['TWITTER_SECRET']