Skip to content

Commit

Permalink
GRN2-107: Add office365 auth (bigbluebutton#616)
Browse files Browse the repository at this point in the history
* add office365 auth

* Delete conflicting file
  • Loading branch information
shawn-higgins1 authored and jfederico committed Jul 9, 2019
1 parent 40b05b1 commit fc18976
Show file tree
Hide file tree
Showing 22 changed files with 53 additions and 43 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ gem 'bcrypt', '~> 3.1.7'
gem 'omniauth'
gem 'omniauth-twitter'
gem 'omniauth-google-oauth2'
gem 'omniauth-microsoft-office365', '~> 0.0.7'
gem 'omniauth-bn-office365', git: 'https://github.com/blindsidenetworks/omniauth-azure-ad.git'
gem 'omniauth-ldap'
gem 'omniauth-bn-launcher', '~> 0.1.0'

Expand Down
13 changes: 9 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
GIT
remote: https://github.com/blindsidenetworks/omniauth-azure-ad.git
revision: c0c7d4dfb4fa4e66986dba6b436a924d83e48377
specs:
omniauth-bn-office365 (1.0.0)
omniauth (>= 1.3.2)
omniauth-oauth2 (>= 1.5.0)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -155,9 +163,6 @@ GEM
omniauth (~> 1.0)
pyu-ruby-sasl (~> 0.0.3.2)
rubyntlm (~> 0.3.4)
omniauth-microsoft-office365 (0.0.7)
omniauth
omniauth-oauth2
omniauth-oauth (1.1.0)
oauth
omniauth (~> 1.0)
Expand Down Expand Up @@ -341,9 +346,9 @@ DEPENDENCIES
mini_racer
omniauth
omniauth-bn-launcher (~> 0.1.0)
omniauth-bn-office365!
omniauth-google-oauth2
omniauth-ldap
omniauth-microsoft-office365 (~> 0.0.7)
omniauth-twitter
pagy
pg (~> 0.18)
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
}
}

.customBtn-microsoft_office365 {
.customBtn-office365 {
@extend .customBtn;
background: #f65314;

Expand Down
24 changes: 15 additions & 9 deletions app/helpers/sessions_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,23 @@ def parse_user_domain(hostname)
end

def omniauth_options(env)
gl_redirect_url = (Rails.env.production? ? "https" : env["rack.url_scheme"]) + "://" + env["SERVER_NAME"] + ":" +
env["SERVER_PORT"]
user_domain = parse_user_domain(env["SERVER_NAME"])
env['omniauth.strategy'].options[:customer] = user_domain
env['omniauth.strategy'].options[:gl_redirect_url] = gl_redirect_url
env['omniauth.strategy'].options[:default_callback_url] = Rails.configuration.gl_callback_url
env['omniauth.strategy'].options[:checksum] = generate_checksum(user_domain, gl_redirect_url,
Rails.configuration.launcher_secret)
if env['omniauth.strategy'].options[:name] == "bn-launcher"
gl_redirect_url = (Rails.env.production? ? "https" : env["rack.url_scheme"]) + "://" + env["SERVER_NAME"] + ":" +
env["SERVER_PORT"]
user_domain = parse_user_domain(env["SERVER_NAME"])
env['omniauth.strategy'].options[:customer] = user_domain
env['omniauth.strategy'].options[:gl_redirect_url] = gl_redirect_url
env['omniauth.strategy'].options[:default_callback_url] = Rails.configuration.gl_callback_url
env['omniauth.strategy'].options[:checksum] = generate_checksum(user_domain, gl_redirect_url,
Rails.configuration.launcher_secret)
elsif env['omniauth.strategy'].options[:name] == "google"
set_hd(env, ENV['GOOGLE_OAUTH2_HD'])
elsif env['omniauth.strategy'].options[:name] == "office365"
set_hd(env, ENV['OFFICE365_HD'])
end
end

def google_omniauth_hd(env, hd)
def set_hd(env, hd)
hd_opts = hd.split(',')
env['omniauth.strategy'].options[:hd] =
if hd_opts.empty?
Expand Down
4 changes: 2 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def from_omniauth(auth)
# Provider attributes.
def auth_name(auth)
case auth['provider']
when :microsoft_office365
when :office365
auth['info']['display_name']
else
auth['info']['name']
Expand All @@ -97,7 +97,7 @@ def auth_image(auth)
when :twitter
auth['info']['image'].gsub("http", "https").gsub("_normal", "")
else
auth['info']['image'] unless auth['provider'] == :microsoft_office365
auth['info']['image']
end
end
end
Expand Down
20 changes: 9 additions & 11 deletions config/initializers/omniauth.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'office365'

# List of supported Omniauth providers.
Rails.application.config.providers = []

Expand All @@ -10,19 +12,14 @@
ENV['LDAP_PASSWORD'].present?
Rails.application.config.omniauth_twitter = ENV['TWITTER_ID'].present? && ENV['TWITTER_SECRET'].present?
Rails.application.config.omniauth_google = ENV['GOOGLE_OAUTH2_ID'].present? && ENV['GOOGLE_OAUTH2_SECRET'].present?
Rails.application.config.omniauth_microsoft_office365 = ENV['OFFICE365_KEY'].present? &&
ENV['OFFICE365_SECRET'].present?
Rails.application.config.omniauth_office365 = ENV['OFFICE365_KEY'].present? &&
ENV['OFFICE365_SECRET'].present?

# If LDAP is enabled, override and disable allow_user_signup.
Rails.application.config.allow_user_signup = false if Rails.application.config.omniauth_ldap

SETUP_PROC = lambda do |env|
provider = env['omniauth.strategy'].options[:name]
if provider == "google"
SessionsController.helpers.google_omniauth_hd env, ENV['GOOGLE_OAUTH2_HD']
else
SessionsController.helpers.omniauth_options env
end
SessionsController.helpers.omniauth_options env
end

# Setup the Omniauth middleware.
Expand Down Expand Up @@ -59,10 +56,11 @@
name: 'google',
setup: SETUP_PROC
end
if Rails.configuration.omniauth_microsoft_office365
Rails.application.config.providers << :microsoft_office365
if Rails.configuration.omniauth_office365
Rails.application.config.providers << :office365

provider :microsoft_office365, ENV['OFFICE365_KEY'], ENV['OFFICE365_SECRET']
provider :office365, ENV['OFFICE365_KEY'], ENV['OFFICE365_SECRET'],
setup: SETUP_PROC
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion config/locales/ar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ ar:
password_different_notice: تأكيد كلمة المرور غير متطابق.
provider:
google: Google
microsoft_office365: Office 365
office365: Office 365
twitter: Twitter
recording:
email: " البريد الإلكتروني للتسجيل"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/de_DE.yml
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ de_DE:
password_different_notice: Passwortbestätigung ist nicht zutreffend.
provider:
google: Google
microsoft_office365: Office 365
office365: Office 365
twitter: Twitter
recaptcha:
errors:
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ en:
password_different_notice: Password Confirmation does not match.
provider:
google: Google
microsoft_office365: Office 365
office365: Office 365
twitter: Twitter
recaptcha:
errors:
Expand Down
2 changes: 1 addition & 1 deletion config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ es:
password_different_notice: La confirmación de password no coincide
provider:
google: Google
microsoft_office365: Office 365
office365: Office 365
twitter: Twitter
recaptcha:
errors:
Expand Down
2 changes: 1 addition & 1 deletion config/locales/es_MX.yml
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ es_MX:
password_different_notice: La confirmación de password no coincide
provider:
google: Google
microsoft_office365: Office 365
office365: Office 365
twitter: Twitter
recaptcha:
errors:
Expand Down
2 changes: 1 addition & 1 deletion config/locales/fa_IR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ fa_IR:
password_different_notice: تاییدیه رمز عبور با رمز ارائه شده مطابقت ندارد.
provider:
google: گوگل
microsoft_office365: افیس 365
office365: افیس 365
twitter: توییتر
recaptcha:
errors:
Expand Down
2 changes: 1 addition & 1 deletion config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ fr:
password_different_notice: La confirmation du mot de passe ne correspond pas.
provider:
google: Google
microsoft_office365: Office 365
office365: Office 365
twitter: Twitter
recording:
email: Envoyer l'enregistrement par Email
Expand Down
2 changes: 1 addition & 1 deletion config/locales/hi_IN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ hi_IN:
password_different_notice: पासवर्ड की पुष्टि मेल नहीं खाती।
provider:
google: गूगल
microsoft_office365: ऑफिस 365
office365: ऑफिस 365
twitter: ट्विटर
recording:
email: ईमेल रिकॉर्डिंग
Expand Down
2 changes: 1 addition & 1 deletion config/locales/hu_HU.yml
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ hu_HU:
password_different_notice: A két új jelszó eltér egymástól.
provider:
google: Google
microsoft_office365: Office 365
office365: Office 365
twitter: Twitter
recaptcha:
errors:
Expand Down
2 changes: 1 addition & 1 deletion config/locales/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ it:
password_different_notice: La conferma della password non coincide.
provider:
google: Google
microsoft_office365: Office 365
office365: Office 365
twitter: Twitter
recaptcha:
errors:
Expand Down
2 changes: 1 addition & 1 deletion config/locales/pt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pt:
password_different_notice: A Confirmação de Senha não corresponde a Senha inserida acima.
provider:
google: Google
microsoft_office365: Office 365
office365: Office 365
twitter: Twitter
recording:
email: Enviar Gravação por E-mail
Expand Down
2 changes: 1 addition & 1 deletion config/locales/pt_BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pt_BR:
password_different_notice: A confirmação de senha não confere.
provider:
google: Google
microsoft_office365: Office 365
office365: Office 365
twitter: Twitter
recording:
email: Enviar link da gravação por e-mail
Expand Down
2 changes: 1 addition & 1 deletion config/locales/ru_RU.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ ru_RU:
password_different_notice: Подтверждение пароля не совпадает.
provider:
google: Google
microsoft_office365: Office 365
office365: Office 365
twitter: Twitter
recording:
email: Отправить ссылку на запись
Expand Down
2 changes: 1 addition & 1 deletion config/locales/vi_VN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ vi_VN:
password_different_notice: Xác nhận mật khẩu không khớp.
provider:
google: Google
microsoft_office365: Office 365
office365: Office 365
twitter: Twitter
recaptcha:
errors:
Expand Down
2 changes: 1 addition & 1 deletion config/locales/zh_CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ zh_CN:
password_different_notice: 两次新密码不一致。
provider:
google: Google
microsoft_office365: Office 365
office365: Office 365
twitter: Twitter
recaptcha:
errors:
Expand Down
1 change: 1 addition & 0 deletions sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ TWITTER_SECRET=
#
OFFICE365_KEY=
OFFICE365_SECRET=
OFFICE365_HD=

# LDAP Login Provider (optional)
#
Expand Down

0 comments on commit fc18976

Please sign in to comment.