Skip to content

Commit

Permalink
Switch from allowed domains to hd
Browse files Browse the repository at this point in the history
  • Loading branch information
shawn-higgins1 committed Jul 8, 2019
1 parent 6167940 commit c0c7d4d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/omniauth/strategies/office365.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Office365 < OmniAuth::Strategies::OAuth2
token_url: '/common/oauth2/v2.0/token'

# Send the scope parameter during authorize
option :authorize_options, [:scope, :allowed_domains]
option :authorize_options, [:scope, :hd]

# Unique ID for the user is the id field
uid { raw_info['id'] }
Expand All @@ -46,7 +46,7 @@ def raw_info

def authorize_params
super.tap do |params|
%w[display allowed_domains scope auth_type].each do |v|
%w[display hd scope auth_type].each do |v|
params[v.to_sym] = request.params[v] if request.params[v]
end

Expand Down Expand Up @@ -86,11 +86,11 @@ def avatar_file
def verify_hd
token = access_token.get('https://graph.microsoft.com/v1.0/me').parsed

return token unless options.allowed_domains
return token unless options.hd

email = token["mail"] || token["userPrincipalName"]

unless options.allowed_domains.split(',').include?(email.split("@")[1])
unless options.hd.split(',').include?(email.split("@")[1])
raise CallbackError.new(:invalid_hd, 'Invalid Hosted Domain')
end

Expand Down

0 comments on commit c0c7d4d

Please sign in to comment.