lib/omniauth/strategies/azure_oauth2.rb in omniauth-azure-oauth2-0.0.6 vs lib/omniauth/strategies/azure_oauth2.rb in omniauth-azure-oauth2-0.0.8
- old
+ new
@@ -2,11 +2,11 @@
require 'jwt'
module OmniAuth
module Strategies
class AzureOauth2 < OmniAuth::Strategies::OAuth2
- BASE_AZURE_URL = 'https://login.windows.net'
+ BASE_AZURE_URL = 'https://login.microsoftonline.com'
option :name, 'azure_oauth2'
option :tenant_provider, nil
@@ -23,14 +23,15 @@
provider = options # if pass has to config, get mapped right on to ptions
end
options.client_id = provider.client_id
options.client_secret = provider.client_secret
- options.tenant_id =
+ options.tenant_id =
provider.respond_to?(:tenant_id) ? provider.tenant_id : 'common'
options.authorize_params.domain_hint = provider.domain_hint if provider.respond_to?(:domain_hint) && provider.domain_hint
+ options.authorize_params.prompt = request.params['prompt'] if request.params['prompt']
options.client_options.authorize_url = "#{BASE_AZURE_URL}/#{options.tenant_id}/oauth2/authorize"
options.client_options.token_url = "#{BASE_AZURE_URL}/#{options.tenant_id}/oauth2/token"
options.token_params.resource = options.resource
super
@@ -45,13 +46,17 @@
name: raw_info['name'],
nickname: raw_info['unique_name'],
first_name: raw_info['given_name'],
last_name: raw_info['family_name'],
email: raw_info['email'] || raw_info['upn'],
- oid: raw_info['oid']
+ oid: raw_info['oid'],
+ tid: raw_info['tid']
}
end
+ def callback_url
+ full_host + script_name + callback_path
+ end
def raw_info
# it's all here in JWT http://msdn.microsoft.com/en-us/library/azure/dn195587.aspx
@raw_info ||= ::JWT.decode(access_token.token, nil, false).first
end