Skip to content

Commit 78b39f5

Browse files
committed
Merge pull request marknadig#11 from hengyiliu/add-prompt
allow prompt parameter
2 parents 329d475 + ed45d19 commit 78b39f5

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

lib/omniauth/azure_oauth2/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module OmniAuth
22
module AzureOauth2
3-
VERSION = "0.0.6"
3+
VERSION = "0.0.7"
44
end
55
end

lib/omniauth/strategies/azure_oauth2.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def client
2929
provider.respond_to?(:tenant_id) ? provider.tenant_id : 'common'
3030

3131
options.authorize_params.domain_hint = provider.domain_hint if provider.respond_to?(:domain_hint) && provider.domain_hint
32+
options.authorize_params.prompt = request.params['prompt'] if request.params['prompt']
3233
options.client_options.authorize_url = "#{BASE_AZURE_URL}/#{options.tenant_id}/oauth2/authorize"
3334
options.client_options.token_url = "#{BASE_AZURE_URL}/#{options.tenant_id}/oauth2/token"
3435

spec/omniauth/strategies/azure_oauth2_spec.rb

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,31 @@ module JWT; end
3131

3232
describe '#client' do
3333
it 'has correct authorize url' do
34+
allow(subject).to receive(:request) { request }
3435
expect(subject.client.options[:authorize_url]).to eql('https://login.microsoftonline.com/tenant/oauth2/authorize')
3536
end
3637

3738
it 'has correct authorize params' do
39+
allow(subject).to receive(:request) { request }
3840
subject.client
3941
expect(subject.authorize_params[:domain_hint]).to be_nil
4042
end
4143

4244
it 'has correct token url' do
45+
allow(subject).to receive(:request) { request }
4346
expect(subject.client.options[:token_url]).to eql('https://login.microsoftonline.com/tenant/oauth2/token')
4447
end
4548

4649
it 'has correct token params' do
50+
allow(subject).to receive(:request) { request }
4751
subject.client
4852
expect(subject.token_params[:resource]).to eql('00000002-0000-0000-c000-000000000000')
4953
end
5054

5155
describe "overrides" do
5256
it 'should override domain_hint' do
5357
@options = {domain_hint: 'hint'}
58+
allow(subject).to receive(:request) { request }
5459
subject.client
5560
expect(subject.authorize_params[:domain_hint]).to eql('hint')
5661
end
@@ -65,6 +70,10 @@ module JWT; end
6570
OmniAuth::Strategies::AzureOauth2.new(app, {client_id: 'id', client_secret: 'secret'}.merge(options))
6671
end
6772

73+
before do
74+
allow(subject).to receive(:request) { request }
75+
end
76+
6877
describe '#client' do
6978
it 'has correct authorize url' do
7079
expect(subject.client.options[:authorize_url]).to eql('https://login.microsoftonline.com/common/oauth2/authorize')
@@ -101,6 +110,10 @@ def tenant_id
101110
OmniAuth::Strategies::AzureOauth2.new(app, provider_klass)
102111
end
103112

113+
before do
114+
allow(subject).to receive(:request) { request }
115+
end
116+
104117
describe '#client' do
105118
it 'has correct authorize url' do
106119
expect(subject.client.options[:authorize_url]).to eql('https://login.microsoftonline.com/tenant/oauth2/authorize')
@@ -152,6 +165,10 @@ def client_secret
152165
OmniAuth::Strategies::AzureOauth2.new(app, provider_klass)
153166
end
154167

168+
before do
169+
allow(subject).to receive(:request) { request }
170+
end
171+
155172
describe '#client' do
156173
it 'has correct authorize url' do
157174
expect(subject.client.options[:authorize_url]).to eql('https://login.microsoftonline.com/common/oauth2/authorize')
@@ -176,8 +193,9 @@ def client_secret
176193
double(:token => token)
177194
end
178195

179-
before :each do
196+
before do
180197
allow(subject).to receive(:access_token) { access_token }
198+
allow(subject).to receive(:request) { request }
181199
end
182200

183201
it "does not clash if JWT strategy is used" do

0 commit comments

Comments
 (0)