diff --git a/Gemfile b/Gemfile index e20c06e7..df6935c4 100644 --- a/Gemfile +++ b/Gemfile @@ -47,6 +47,7 @@ gem 'bcrypt', '~> 3.1.7' gem 'omniauth' gem 'omniauth-twitter' gem 'omniauth-google-oauth2' +gem 'omniauth-microsoft-office365', '~> 0.0.7' gem 'omniauth-ldap' gem 'omniauth-bn-launcher', '~> 0.1.0' diff --git a/Gemfile.lock b/Gemfile.lock index 0401dd50..e1686115 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -160,6 +160,9 @@ GEM omniauth (~> 1.8.1) pyu-ruby-sasl (~> 0.0.3.3) rubyntlm (~> 0.6.2) + omniauth-microsoft-office365 (0.0.7) + omniauth + omniauth-oauth2 omniauth-oauth (1.1.0) oauth omniauth (~> 1.0) @@ -338,6 +341,7 @@ DEPENDENCIES omniauth-bn-launcher (~> 0.1.0) omniauth-google-oauth2 omniauth-ldap + omniauth-microsoft-office365 (~> 0.0.7) omniauth-twitter pg (~> 0.18) puma (~> 3.0) diff --git a/app/models/user.rb b/app/models/user.rb index 68dcb033..72b7a680 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -60,7 +60,12 @@ class User < ApplicationRecord # Provider attributes. def auth_name(auth) - auth['info']['name'] + case auth['provider'] + when :microsoft_office365 + auth['info']['display_name'] + else + auth['info']['name'] + end end def auth_username(auth) @@ -83,7 +88,7 @@ class User < ApplicationRecord when :twitter auth['info']['image'].gsub("http", "https").gsub("_normal", "") else - auth['info']['image'] + auth['info']['image'] unless auth['provider'] == :microsoft_office365 end end end diff --git a/app/views/shared/modals/_login_modal.html.erb b/app/views/shared/modals/_login_modal.html.erb index eeedd249..6595d54a 100644 --- a/app/views/shared/modals/_login_modal.html.erb +++ b/app/views/shared/modals/_login_modal.html.erb @@ -41,6 +41,12 @@ <% end %> <% end %> + <% if configured_providers.include? :microsoft_office365 %> + <%= link_to omniauth_login_url(:microsoft_office365), class: "btn btn-pill btn-primary btn-block" do %> +  <%= t("modal.login.with", provider: "Office365") %> + <% end %> + <% end %> +
diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index d8f3eb51..2247a4bf 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -40,6 +40,12 @@ <% end %> <% end %> + <% if configured_providers.include? :microsoft_office365 %> + <%= link_to omniauth_login_url(:microsoft_office365), class: "btn btn-pill btn-primary btn-block" do %> +  <%= t("signup.with", provider: "Office365") %> + <% end %> + <% end %> +
diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index 36ba12cf..01626245 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -1,11 +1,13 @@ # frozen_string_literal: true # List of supported Omniauth providers. -Rails.application.config.providers = [:google, :twitter, :ldap] +Rails.application.config.providers = [:google, :twitter, :microsoft_office365, :ldap] # Set which providers are configured. Rails.application.config.omniauth_google = ENV['GOOGLE_OAUTH2_ID'].present? && ENV['GOOGLE_OAUTH2_SECRET'].present? Rails.application.config.omniauth_twitter = ENV['TWITTER_ID'].present? && ENV['TWITTER_SECRET'].present? +Rails.application.config.omniauth_microsoft_office365 = ENV['OFFICE365_KEY'].present? && + ENV['OFFICE365_SECRET'].present? Rails.application.config.omniauth_ldap = ENV['LDAP_SERVER'].present? && ENV['LDAP_UID'].present? && ENV['LDAP_BASE'].present? && ENV['LDAP_BIND_DN'].present? && ENV['LDAP_PASSWORD'].present? @@ -35,6 +37,8 @@ Rails.application.config.middleware.use OmniAuth::Builder do name: 'google', hd: ENV['GOOGLE_OAUTH2_HD'].blank? ? nil : ENV['GOOGLE_OAUTH2_HD'] + provider :microsoft_office365, ENV['OFFICE365_KEY'], ENV['OFFICE365_SECRET'] + provider :ldap, host: ENV['LDAP_SERVER'], port: ENV['LDAP_PORT'] || '389', diff --git a/sample.env b/sample.env index 94391047..5c0b9af2 100644 --- a/sample.env +++ b/sample.env @@ -38,6 +38,15 @@ GOOGLE_OAUTH2_HD= TWITTER_ID= TWITTER_SECRET= +# Microsoft Office365 Login Provider (optional) +# +# For in-depth steps on setting up a Office 365 Login Provider, see: +# +# http://docs.bigbluebutton.org/install/greenlight-v2.html#office365-oauth2 +# +OFFICE365_KEY= +OFFICE365_SECRET= + # LDAP Login Provider (optional) # # You can enable LDAP authentication by providing values for the variables below.