Class: OmniAuth::Strategies::MicrosoftIdentity2

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

Overview

OmniAuth strategy for Microsoft Identity (Entra ID) OAuth2/OpenID Connect.

Direct Known Subclasses

MicrosoftIdentity, Windowslive

Constant Summary collapse

BASE_URL =
"https://login.microsoftonline.com"
DEFAULT_SCOPE =
"openid profile email offline_access User.Read"
USER_INFO_URL =
"https://graph.microsoft.com/oidc/userinfo"
GRAPH_ME_URL =
"https://graph.microsoft.com/v1.0/me"

Instance Method Summary collapse

Instance Method Details

#authorize_paramsObject



84
85
86
87
88
89
90
# File 'lib/omniauth/strategies/microsoft_identity2.rb', line 84

def authorize_params
  super.tap do |params|
    apply_request_authorize_overrides(params)
    params[:scope] = normalize_scope(params[:scope] || options[:scope])
    persist_authorize_state(params)
  end
end

#callback_phaseObject



102
103
104
105
106
107
108
109
110
# File 'lib/omniauth/strategies/microsoft_identity2.rb', line 102

def callback_phase
  return fail_state_mismatch if missing_session_state?

  super
rescue NoMethodError => e
  raise unless oauth_state_nil_compare_error?(e)

  fail_state_mismatch
end

#callback_urlObject

Ensure token exchange uses a stable callback URI that matches provider config.



113
114
115
# File 'lib/omniauth/strategies/microsoft_identity2.rb', line 113

def callback_url
  options[:callback_url] || options[:redirect_uri] || super
end

#clientObject



79
80
81
82
# File 'lib/omniauth/strategies/microsoft_identity2.rb', line 79

def client
  configure_tenant_client_urls
  super
end

#query_stringObject

Prevent authorization response params from being appended to redirect_uri.



118
119
120
121
122
# File 'lib/omniauth/strategies/microsoft_identity2.rb', line 118

def query_string
  return "" if request.params["code"]

  super
end

#raw_infoObject



92
93
94
95
96
97
98
99
100
# File 'lib/omniauth/strategies/microsoft_identity2.rb', line 92

def raw_info
  @raw_info ||= begin
    claims = {}
    decoded = decoded_id_token
    claims.merge!(decoded) if decoded
    claims.merge!()
    claims
  end
end