Skip to content

Commit

Permalink
Fixed bigbluebutton#291 Added OAuth2 for Office365 (GRN-32) (bigblueb…
Browse files Browse the repository at this point in the history
…utton#293)

* <Added omniauth for office365>

* <Fixed code style>

* Update puma.rb

* <Inserted link to documentation>
  • Loading branch information
jiama843 authored and jfederico committed Oct 16, 2018
1 parent 90b965d commit ec250f3
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 3 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ def from_omniauth(auth)

# 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)
Expand All @@ -83,7 +88,7 @@ def auth_image(auth)
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
Expand Down
6 changes: 6 additions & 0 deletions app/views/shared/modals/_login_modal.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
<i class="fab fa-windows"></i>&ensp;<%= t("modal.login.with", provider: "Office365") %>
<% end %>
<% end %>

<div class="or-line my-6">
<div>
<span class="text-uppercase">
Expand Down
6 changes: 6 additions & 0 deletions app/views/users/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
<i class="fab fa-windows"></i>&ensp;<%= t("signup.with", provider: "Office365") %>
<% end %>
<% end %>

<div class="or-line my-3">
<div>
<span class="text-uppercase" style="background-color: #F5F7FB;">
Expand Down
6 changes: 5 additions & 1 deletion config/initializers/omniauth.rb
Original file line number Diff line number Diff line change
@@ -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?
Expand Down Expand Up @@ -35,6 +37,8 @@
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',
Expand Down
9 changes: 9 additions & 0 deletions sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit ec250f3

Please sign in to comment.