...
 
Commits (5)
# Version 0.0.9
* Expand JWT dep. Thanks @ronaldsalas
# Version 0.0.9
* Added support for dynamic tenant urls. Thanks @marcus-fellinger-esc
......
ruby-omniauth-azure-oauth2 (0.0.10-1) unstable; urgency=medium
* Team upload
* New upstream version 0.0.10
* Use salsa.debian.org in Vcs-* fields
* Bump Standards-Version to 4.3.0 (no changes needed)
-- Pirate Praveen <praveen@debian.org> Tue, 05 Mar 2019 11:48:20 +0530
ruby-omniauth-azure-oauth2 (0.0.9-2) unstable; urgency=medium
* Team upload
......
......@@ -11,9 +11,9 @@ Build-Depends: debhelper (>= 11~),
ruby-omniauth-oauth2 (>= 1.1),
ruby-rspec,
ruby-sinatra
Standards-Version: 4.1.3
Vcs-Git: https://anonscm.debian.org/git/pkg-ruby-extras/ruby-omniauth-azure-oauth2.git
Vcs-Browser: https://anonscm.debian.org/cgit/pkg-ruby-extras/ruby-omniauth-azure-oauth2.git
Standards-Version: 4.3.0
Vcs-Git: https://salsa.debian.org/ruby-team/ruby-omniauth-azure-oauth2.git
Vcs-Browser: https://salsa.debian.org/ruby-team/ruby-omniauth-azure-oauth2
Homepage: https://github.com/KonaTeam/omniauth-azure-oauth2
Testsuite: autopkgtest-pkg-ruby
XS-Ruby-Versions: all
......
module OmniAuth
module AzureOauth2
VERSION = "0.0.9"
VERSION = "0.0.10"
end
end
......@@ -27,15 +27,14 @@ module OmniAuth
options.client_secret = provider.client_secret
options.tenant_id =
provider.respond_to?(:tenant_id) ? provider.tenant_id : 'common'
options.base_azure_url =
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'}
......@@ -69,30 +63,30 @@ describe OmniAuth::Strategies::AzureOauth2 do
subject do
OmniAuth::Strategies::AzureOauth2.new(app, {client_id: 'id', client_secret: 'secret', tenant_id: 'tenant', base_azure_url: 'https://login.microsoftonline.de'}.merge(options))
end
describe '#client' do
it 'has correct authorize url' do
allow(subject).to receive(:request) { request }
expect(subject.client.options[:authorize_url]).to eql('https://login.microsoftonline.de/tenant/oauth2/authorize')
end
it 'has correct authorize params' do
allow(subject).to receive(:request) { request }
subject.client
expect(subject.authorize_params[:domain_hint]).to be_nil
end
it 'has correct token url' do
allow(subject).to receive(:request) { request }
expect(subject.client.options[:token_url]).to eql('https://login.microsoftonline.de/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'}
......@@ -103,7 +97,7 @@ describe OmniAuth::Strategies::AzureOauth2 do
end
end
end
describe 'static common configuration' do
let(:options) { @options || {} }
subject do
......@@ -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
......@@ -190,52 +188,52 @@ describe OmniAuth::Strategies::AzureOauth2 do
Class.new {
def initialize(strategy)
end
def client_id
'id'
end
def client_secret
'secret'
end
def tenant_id
'tenant'
end
def base_azure_url
'https://login.microsoftonline.de'
end
}
}
subject do
OmniAuth::Strategies::AzureOauth2.new(app, provider_klass)
end
before do
allow(subject).to receive(:request) { request }
end
describe '#client' do
it 'has correct authorize url' do
expect(subject.client.options[:authorize_url]).to eql('https://login.microsoftonline.de/tenant/oauth2/authorize')
end
it 'has correct authorize params' do
subject.client
expect(subject.authorize_params[:domain_hint]).to be_nil
end
it 'has correct token url' do
expect(subject.client.options[:token_url]).to eql('https://login.microsoftonline.de/tenant/oauth2/token')
end
it 'has correct token params' do
subject.client
expect(subject.token_params[:resource]).to eql('00000002-0000-0000-c000-000000000000')
end
# todo: how to get this working?
# describe "overrides" do
# it 'should override domain_hint' do
......@@ -245,7 +243,7 @@ describe OmniAuth::Strategies::AzureOauth2 do
# end
# end
end
end
describe 'dynamic common configuration' 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