Class: OmniAuth::Strategies::Office365

Inherits:
OAuth2
  • Object
show all
Defined in:
lib/omniauth/strategies/office365.rb

Overview

Implements an OmniAuth strategy to get a Microsoft Graph compatible token from Azure AD

Constant Summary collapse

DEFAULT_SCOPE =
'openid email profile User.Read'

Instance Method Summary collapse

Instance Method Details

#authorize_paramsObject



47
48
49
50
51
52
53
54
55
# File 'lib/omniauth/strategies/office365.rb', line 47

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

    params[:scope] ||= DEFAULT_SCOPE
  end
end

#callback_urlObject

Override callback URL OmniAuth by default passes the entire URL of the callback, including query parameters. Azure fails validation because that doesn’t match the registered callback.



61
62
63
# File 'lib/omniauth/strategies/office365.rb', line 61

def callback_url
  options[:redirect_uri] || (full_host + script_name + callback_path)
end

#raw_infoObject



41
42
43
44
45
# File 'lib/omniauth/strategies/office365.rb', line 41

def raw_info
  # Get user profile information from the /me endpoint
  @raw_info ||= verify_hd
  @raw_info
end