New upstream version 0.0.10

parent b419fe76
# Version 0.0.9
* Expand JWT dep. Thanks @ronaldsalas
# Version 0.0.9
* Added support for dynamic tenant urls. Thanks @marcus-fellinger-esc
......
module OmniAuth
module AzureOauth2
VERSION = "0.0.9"
VERSION = "0.0.10"
end
end
......@@ -30,12 +30,11 @@ module OmniAuth
options.base_azure_url =
provider.respond_to?(:base_azure_url) ? provider.base_azure_url : BASE_AZURE_URL
options.authorize_params = provider.authorize_params if provider.respond_to?(:authorize_params)
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 = "#{options.base_azure_url}/#{options.tenant_id}/oauth2/authorize"
options.client_options.token_url = "#{options.base_azure_url}/#{options.tenant_id}/oauth2/token"
options.token_params.resource = options.resource
super
end
......@@ -55,6 +54,11 @@ module OmniAuth
}
end
def token_params
azure_resource = request.env['omniauth.params'] && request.env['omniauth.params']['azure_resource']
super.merge(resource: azure_resource || options.resource)
end
def callback_url
full_host + script_name + callback_path
end
......
......@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
gem.license = "MIT"
gem.add_dependency 'omniauth', '~> 1.0'
gem.add_dependency 'jwt', '~> 1.0'
gem.add_dependency 'jwt', ['>= 1.0', '< 3.0']
gem.add_runtime_dependency 'omniauth-oauth2', '~> 1.4'
......
......@@ -46,12 +46,6 @@ describe OmniAuth::Strategies::AzureOauth2 do
expect(subject.client.options[:token_url]).to eql('https://login.microsoftonline.com/tenant/oauth2/token')
end
it 'has correct token params' do
allow(subject).to receive(:request) { request }
subject.client
expect(subject.token_params[:resource]).to eql('00000002-0000-0000-c000-000000000000')
end
describe "overrides" do
it 'should override domain_hint' do
@options = {domain_hint: 'hint'}
......@@ -143,6 +137,9 @@ describe OmniAuth::Strategies::AzureOauth2 do
'tenant'
end
def authorize_params
{ custom_option: 'value' }
end
}
}
......@@ -162,6 +159,7 @@ describe OmniAuth::Strategies::AzureOauth2 do
it 'has correct authorize params' do
subject.client
expect(subject.authorize_params[:domain_hint]).to be_nil
expect(subject.authorize_params[:custom_option]).to eql('value')
end
it 'has correct token url' do
......@@ -307,4 +305,28 @@ describe OmniAuth::Strategies::AzureOauth2 do
end.to_not raise_error
end
end
describe 'token_params' do
let(:strategy) { OmniAuth::Strategies::AzureOauth2.new(app, client_id: 'id', client_secret: 'secret') }
let(:request) { double('Request', env: env) }
let(:env) { {} }
subject { strategy.token_params }
before { allow(strategy).to receive(:request).and_return request }
it { is_expected.to be_a OmniAuth::Strategy::Options }
it 'has default resource' do
expect(subject.resource).to eq '00000002-0000-0000-c000-000000000000'
end
context 'when custom crm url' do
let(:crm_url) { 'https://mydomain.crm.dynamics.com/' }
let(:env) { { 'omniauth.params' => { 'azure_resource' => crm_url } } }
it 'has resource from url params' do
expect(subject.resource).to eq crm_url
end
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment