forked from External/greenlight
GRN2-107: Add office365 auth (#616)
* add office365 auth * Delete conflicting file
This commit is contained in:
parent
40b05b1626
commit
fc18976b6d
2
Gemfile
2
Gemfile
|
@ -44,7 +44,7 @@ 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-microsoft-office365', '~> 0.0.7'
|
gem 'omniauth-bn-office365', git: 'https://github.com/blindsidenetworks/omniauth-azure-ad.git'
|
||||||
gem 'omniauth-ldap'
|
gem 'omniauth-ldap'
|
||||||
gem 'omniauth-bn-launcher', '~> 0.1.0'
|
gem 'omniauth-bn-launcher', '~> 0.1.0'
|
||||||
|
|
||||||
|
|
13
Gemfile.lock
13
Gemfile.lock
|
@ -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
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
|
@ -155,9 +163,6 @@ GEM
|
||||||
omniauth (~> 1.0)
|
omniauth (~> 1.0)
|
||||||
pyu-ruby-sasl (~> 0.0.3.2)
|
pyu-ruby-sasl (~> 0.0.3.2)
|
||||||
rubyntlm (~> 0.3.4)
|
rubyntlm (~> 0.3.4)
|
||||||
omniauth-microsoft-office365 (0.0.7)
|
|
||||||
omniauth
|
|
||||||
omniauth-oauth2
|
|
||||||
omniauth-oauth (1.1.0)
|
omniauth-oauth (1.1.0)
|
||||||
oauth
|
oauth
|
||||||
omniauth (~> 1.0)
|
omniauth (~> 1.0)
|
||||||
|
@ -341,9 +346,9 @@ DEPENDENCIES
|
||||||
mini_racer
|
mini_racer
|
||||||
omniauth
|
omniauth
|
||||||
omniauth-bn-launcher (~> 0.1.0)
|
omniauth-bn-launcher (~> 0.1.0)
|
||||||
|
omniauth-bn-office365!
|
||||||
omniauth-google-oauth2
|
omniauth-google-oauth2
|
||||||
omniauth-ldap
|
omniauth-ldap
|
||||||
omniauth-microsoft-office365 (~> 0.0.7)
|
|
||||||
omniauth-twitter
|
omniauth-twitter
|
||||||
pagy
|
pagy
|
||||||
pg (~> 0.18)
|
pg (~> 0.18)
|
||||||
|
|
|
@ -123,7 +123,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.customBtn-microsoft_office365 {
|
.customBtn-office365 {
|
||||||
@extend .customBtn;
|
@extend .customBtn;
|
||||||
background: #f65314;
|
background: #f65314;
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,7 @@ module SessionsHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def omniauth_options(env)
|
def omniauth_options(env)
|
||||||
|
if env['omniauth.strategy'].options[:name] == "bn-launcher"
|
||||||
gl_redirect_url = (Rails.env.production? ? "https" : env["rack.url_scheme"]) + "://" + env["SERVER_NAME"] + ":" +
|
gl_redirect_url = (Rails.env.production? ? "https" : env["rack.url_scheme"]) + "://" + env["SERVER_NAME"] + ":" +
|
||||||
env["SERVER_PORT"]
|
env["SERVER_PORT"]
|
||||||
user_domain = parse_user_domain(env["SERVER_NAME"])
|
user_domain = parse_user_domain(env["SERVER_NAME"])
|
||||||
|
@ -86,9 +87,14 @@ module SessionsHelper
|
||||||
env['omniauth.strategy'].options[:default_callback_url] = Rails.configuration.gl_callback_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,
|
env['omniauth.strategy'].options[:checksum] = generate_checksum(user_domain, gl_redirect_url,
|
||||||
Rails.configuration.launcher_secret)
|
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
|
end
|
||||||
|
|
||||||
def google_omniauth_hd(env, hd)
|
def set_hd(env, hd)
|
||||||
hd_opts = hd.split(',')
|
hd_opts = hd.split(',')
|
||||||
env['omniauth.strategy'].options[:hd] =
|
env['omniauth.strategy'].options[:hd] =
|
||||||
if hd_opts.empty?
|
if hd_opts.empty?
|
||||||
|
|
|
@ -70,7 +70,7 @@ class User < ApplicationRecord
|
||||||
# Provider attributes.
|
# Provider attributes.
|
||||||
def auth_name(auth)
|
def auth_name(auth)
|
||||||
case auth['provider']
|
case auth['provider']
|
||||||
when :microsoft_office365
|
when :office365
|
||||||
auth['info']['display_name']
|
auth['info']['display_name']
|
||||||
else
|
else
|
||||||
auth['info']['name']
|
auth['info']['name']
|
||||||
|
@ -97,7 +97,7 @@ class User < ApplicationRecord
|
||||||
when :twitter
|
when :twitter
|
||||||
auth['info']['image'].gsub("http", "https").gsub("_normal", "")
|
auth['info']['image'].gsub("http", "https").gsub("_normal", "")
|
||||||
else
|
else
|
||||||
auth['info']['image'] unless auth['provider'] == :microsoft_office365
|
auth['info']['image']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'office365'
|
||||||
|
|
||||||
# List of supported Omniauth providers.
|
# List of supported Omniauth providers.
|
||||||
Rails.application.config.providers = []
|
Rails.application.config.providers = []
|
||||||
|
|
||||||
|
@ -10,19 +12,14 @@ Rails.application.config.omniauth_ldap = ENV['LDAP_SERVER'].present? && ENV['LDA
|
||||||
ENV['LDAP_PASSWORD'].present?
|
ENV['LDAP_PASSWORD'].present?
|
||||||
Rails.application.config.omniauth_twitter = ENV['TWITTER_ID'].present? && ENV['TWITTER_SECRET'].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_google = ENV['GOOGLE_OAUTH2_ID'].present? && ENV['GOOGLE_OAUTH2_SECRET'].present?
|
||||||
Rails.application.config.omniauth_microsoft_office365 = ENV['OFFICE365_KEY'].present? &&
|
Rails.application.config.omniauth_office365 = ENV['OFFICE365_KEY'].present? &&
|
||||||
ENV['OFFICE365_SECRET'].present?
|
ENV['OFFICE365_SECRET'].present?
|
||||||
|
|
||||||
# If LDAP is enabled, override and disable allow_user_signup.
|
# If LDAP is enabled, override and disable allow_user_signup.
|
||||||
Rails.application.config.allow_user_signup = false if Rails.application.config.omniauth_ldap
|
Rails.application.config.allow_user_signup = false if Rails.application.config.omniauth_ldap
|
||||||
|
|
||||||
SETUP_PROC = lambda do |env|
|
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
|
SessionsController.helpers.omniauth_options env
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Setup the Omniauth middleware.
|
# Setup the Omniauth middleware.
|
||||||
|
@ -59,10 +56,11 @@ Rails.application.config.middleware.use OmniAuth::Builder do
|
||||||
name: 'google',
|
name: 'google',
|
||||||
setup: SETUP_PROC
|
setup: SETUP_PROC
|
||||||
end
|
end
|
||||||
if Rails.configuration.omniauth_microsoft_office365
|
if Rails.configuration.omniauth_office365
|
||||||
Rails.application.config.providers << :microsoft_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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -155,7 +155,7 @@ ar:
|
||||||
password_different_notice: تأكيد كلمة المرور غير متطابق.
|
password_different_notice: تأكيد كلمة المرور غير متطابق.
|
||||||
provider:
|
provider:
|
||||||
google: Google
|
google: Google
|
||||||
microsoft_office365: Office 365
|
office365: Office 365
|
||||||
twitter: Twitter
|
twitter: Twitter
|
||||||
recording:
|
recording:
|
||||||
email: " البريد الإلكتروني للتسجيل"
|
email: " البريد الإلكتروني للتسجيل"
|
||||||
|
|
|
@ -284,7 +284,7 @@ de_DE:
|
||||||
password_different_notice: Passwortbestätigung ist nicht zutreffend.
|
password_different_notice: Passwortbestätigung ist nicht zutreffend.
|
||||||
provider:
|
provider:
|
||||||
google: Google
|
google: Google
|
||||||
microsoft_office365: Office 365
|
office365: Office 365
|
||||||
twitter: Twitter
|
twitter: Twitter
|
||||||
recaptcha:
|
recaptcha:
|
||||||
errors:
|
errors:
|
||||||
|
|
|
@ -300,7 +300,7 @@ en:
|
||||||
password_different_notice: Password Confirmation does not match.
|
password_different_notice: Password Confirmation does not match.
|
||||||
provider:
|
provider:
|
||||||
google: Google
|
google: Google
|
||||||
microsoft_office365: Office 365
|
office365: Office 365
|
||||||
twitter: Twitter
|
twitter: Twitter
|
||||||
recaptcha:
|
recaptcha:
|
||||||
errors:
|
errors:
|
||||||
|
|
|
@ -284,7 +284,7 @@ es:
|
||||||
password_different_notice: La confirmación de password no coincide
|
password_different_notice: La confirmación de password no coincide
|
||||||
provider:
|
provider:
|
||||||
google: Google
|
google: Google
|
||||||
microsoft_office365: Office 365
|
office365: Office 365
|
||||||
twitter: Twitter
|
twitter: Twitter
|
||||||
recaptcha:
|
recaptcha:
|
||||||
errors:
|
errors:
|
||||||
|
|
|
@ -284,7 +284,7 @@ es_MX:
|
||||||
password_different_notice: La confirmación de password no coincide
|
password_different_notice: La confirmación de password no coincide
|
||||||
provider:
|
provider:
|
||||||
google: Google
|
google: Google
|
||||||
microsoft_office365: Office 365
|
office365: Office 365
|
||||||
twitter: Twitter
|
twitter: Twitter
|
||||||
recaptcha:
|
recaptcha:
|
||||||
errors:
|
errors:
|
||||||
|
|
|
@ -283,7 +283,7 @@ fa_IR:
|
||||||
password_different_notice: تاییدیه رمز عبور با رمز ارائه شده مطابقت ندارد.
|
password_different_notice: تاییدیه رمز عبور با رمز ارائه شده مطابقت ندارد.
|
||||||
provider:
|
provider:
|
||||||
google: گوگل
|
google: گوگل
|
||||||
microsoft_office365: افیس 365
|
office365: افیس 365
|
||||||
twitter: توییتر
|
twitter: توییتر
|
||||||
recaptcha:
|
recaptcha:
|
||||||
errors:
|
errors:
|
||||||
|
|
|
@ -155,7 +155,7 @@ fr:
|
||||||
password_different_notice: La confirmation du mot de passe ne correspond pas.
|
password_different_notice: La confirmation du mot de passe ne correspond pas.
|
||||||
provider:
|
provider:
|
||||||
google: Google
|
google: Google
|
||||||
microsoft_office365: Office 365
|
office365: Office 365
|
||||||
twitter: Twitter
|
twitter: Twitter
|
||||||
recording:
|
recording:
|
||||||
email: Envoyer l'enregistrement par Email
|
email: Envoyer l'enregistrement par Email
|
||||||
|
|
|
@ -155,7 +155,7 @@ hi_IN:
|
||||||
password_different_notice: पासवर्ड की पुष्टि मेल नहीं खाती।
|
password_different_notice: पासवर्ड की पुष्टि मेल नहीं खाती।
|
||||||
provider:
|
provider:
|
||||||
google: गूगल
|
google: गूगल
|
||||||
microsoft_office365: ऑफिस 365
|
office365: ऑफिस 365
|
||||||
twitter: ट्विटर
|
twitter: ट्विटर
|
||||||
recording:
|
recording:
|
||||||
email: ईमेल रिकॉर्डिंग
|
email: ईमेल रिकॉर्डिंग
|
||||||
|
|
|
@ -283,7 +283,7 @@ hu_HU:
|
||||||
password_different_notice: A két új jelszó eltér egymástól.
|
password_different_notice: A két új jelszó eltér egymástól.
|
||||||
provider:
|
provider:
|
||||||
google: Google
|
google: Google
|
||||||
microsoft_office365: Office 365
|
office365: Office 365
|
||||||
twitter: Twitter
|
twitter: Twitter
|
||||||
recaptcha:
|
recaptcha:
|
||||||
errors:
|
errors:
|
||||||
|
|
|
@ -284,7 +284,7 @@ it:
|
||||||
password_different_notice: La conferma della password non coincide.
|
password_different_notice: La conferma della password non coincide.
|
||||||
provider:
|
provider:
|
||||||
google: Google
|
google: Google
|
||||||
microsoft_office365: Office 365
|
office365: Office 365
|
||||||
twitter: Twitter
|
twitter: Twitter
|
||||||
recaptcha:
|
recaptcha:
|
||||||
errors:
|
errors:
|
||||||
|
|
|
@ -155,7 +155,7 @@ pt:
|
||||||
password_different_notice: A Confirmação de Senha não corresponde a Senha inserida acima.
|
password_different_notice: A Confirmação de Senha não corresponde a Senha inserida acima.
|
||||||
provider:
|
provider:
|
||||||
google: Google
|
google: Google
|
||||||
microsoft_office365: Office 365
|
office365: Office 365
|
||||||
twitter: Twitter
|
twitter: Twitter
|
||||||
recording:
|
recording:
|
||||||
email: Enviar Gravação por E-mail
|
email: Enviar Gravação por E-mail
|
||||||
|
|
|
@ -155,7 +155,7 @@ pt_BR:
|
||||||
password_different_notice: A confirmação de senha não confere.
|
password_different_notice: A confirmação de senha não confere.
|
||||||
provider:
|
provider:
|
||||||
google: Google
|
google: Google
|
||||||
microsoft_office365: Office 365
|
office365: Office 365
|
||||||
twitter: Twitter
|
twitter: Twitter
|
||||||
recording:
|
recording:
|
||||||
email: Enviar link da gravação por e-mail
|
email: Enviar link da gravação por e-mail
|
||||||
|
|
|
@ -131,7 +131,7 @@ ru_RU:
|
||||||
password_different_notice: Подтверждение пароля не совпадает.
|
password_different_notice: Подтверждение пароля не совпадает.
|
||||||
provider:
|
provider:
|
||||||
google: Google
|
google: Google
|
||||||
microsoft_office365: Office 365
|
office365: Office 365
|
||||||
twitter: Twitter
|
twitter: Twitter
|
||||||
recording:
|
recording:
|
||||||
email: Отправить ссылку на запись
|
email: Отправить ссылку на запись
|
||||||
|
|
|
@ -219,7 +219,7 @@ vi_VN:
|
||||||
password_different_notice: Xác nhận mật khẩu không khớp.
|
password_different_notice: Xác nhận mật khẩu không khớp.
|
||||||
provider:
|
provider:
|
||||||
google: Google
|
google: Google
|
||||||
microsoft_office365: Office 365
|
office365: Office 365
|
||||||
twitter: Twitter
|
twitter: Twitter
|
||||||
recaptcha:
|
recaptcha:
|
||||||
errors:
|
errors:
|
||||||
|
|
|
@ -283,7 +283,7 @@ zh_CN:
|
||||||
password_different_notice: 两次新密码不一致。
|
password_different_notice: 两次新密码不一致。
|
||||||
provider:
|
provider:
|
||||||
google: Google
|
google: Google
|
||||||
microsoft_office365: Office 365
|
office365: Office 365
|
||||||
twitter: Twitter
|
twitter: Twitter
|
||||||
recaptcha:
|
recaptcha:
|
||||||
errors:
|
errors:
|
||||||
|
|
|
@ -47,6 +47,7 @@ TWITTER_SECRET=
|
||||||
#
|
#
|
||||||
OFFICE365_KEY=
|
OFFICE365_KEY=
|
||||||
OFFICE365_SECRET=
|
OFFICE365_SECRET=
|
||||||
|
OFFICE365_HD=
|
||||||
|
|
||||||
# LDAP Login Provider (optional)
|
# LDAP Login Provider (optional)
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue