omniauth-azure-oauth2 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d9149a05139422434d298c3b5a30672d3de6195
4
- data.tar.gz: efe71ff9e3b0e07870ea75f10fad2890b0c8c398
3
+ metadata.gz: b934d53deb625528b9f999ca581fa4c14cffc555
4
+ data.tar.gz: 316f91e22960627a3b9ec1d72c7810a50b927d1d
5
5
  SHA512:
6
- metadata.gz: 126922706272c0a00bb8330e4b10f264c1490ad98ed075b27e7ae9158ec13af20f200f15dbcb29d29dd2ad93d40c645cd92f8a205ba2018e84b1e5d3cca2c4d3
7
- data.tar.gz: e154b9fa94645c9bdffe6cc92b473f0a9d9d8a0e975f4be14004acc3e1afb5418d1411774b881ce8720bfac1a21bfc3b446cc162a370f09f53f17b1860d0a3e1
6
+ metadata.gz: b98d6265575c2f747103a0f329f537ce517ccc5743eda6a8698d4834e0ce74e59789aaad85abc64ba7ef6c31edbc1676bc670806340f38cd73d2073f7c505366
7
+ data.tar.gz: bf2ddfc11a676457d962ea484013f0981f9735a38662203366e07bc17fe813849b1641da1a9dc640eddfe31b9c49a180ed403d310087fa32f52dfcd1842ac962
@@ -1,6 +1,9 @@
1
- # Version 0.0.7
1
+ # Version 0.0.9
2
+ * Added support for dynamic tenant urls. Thanks @marcus-fellinger-esc
3
+
4
+ # Version 0.0.8
2
5
  * Upgrade to omniauth-oauth2 1.4.0 and fix callback url issue
3
- * Allow prompt parameter
6
+ * Allow prompt parameter, thanks @hilu
4
7
  * Add tenant id to info
5
8
  * Updated base url
6
9
 
data/README.md CHANGED
@@ -101,6 +101,9 @@ use OmniAuth::Builder do
101
101
  end
102
102
  ```
103
103
 
104
+ The base_azure_url can be overridden in the provider configuration for different locales; e.g. `base_azure_url: "https://login.microsoftonline.de"`
105
+
106
+
104
107
  ## Auth Hash Schema
105
108
 
106
109
  The following information is provided back to you for this provider:
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module AzureOauth2
3
- VERSION = "0.0.8"
3
+ VERSION = "0.0.9"
4
4
  end
5
5
  end
@@ -13,25 +13,27 @@ module OmniAuth
13
13
  # AD resource identifier
14
14
  option :resource, '00000002-0000-0000-c000-000000000000'
15
15
 
16
- # tenant_provider must return client_id, client_secret and optionally tenant_id
16
+ # tenant_provider must return client_id, client_secret and optionally tenant_id and base_azure_url
17
17
  args [:tenant_provider]
18
18
 
19
19
  def client
20
20
  if options.tenant_provider
21
21
  provider = options.tenant_provider.new(self)
22
22
  else
23
- provider = options # if pass has to config, get mapped right on to ptions
23
+ provider = options # if pass has to config, get mapped right on to options
24
24
  end
25
25
 
26
26
  options.client_id = provider.client_id
27
27
  options.client_secret = provider.client_secret
28
28
  options.tenant_id =
29
29
  provider.respond_to?(:tenant_id) ? provider.tenant_id : 'common'
30
+ options.base_azure_url =
31
+ provider.respond_to?(:base_azure_url) ? provider.base_azure_url : BASE_AZURE_URL
30
32
 
31
33
  options.authorize_params.domain_hint = provider.domain_hint if provider.respond_to?(:domain_hint) && provider.domain_hint
32
34
  options.authorize_params.prompt = request.params['prompt'] if request.params['prompt']
33
- options.client_options.authorize_url = "#{BASE_AZURE_URL}/#{options.tenant_id}/oauth2/authorize"
34
- options.client_options.token_url = "#{BASE_AZURE_URL}/#{options.tenant_id}/oauth2/token"
35
+ options.client_options.authorize_url = "#{options.base_azure_url}/#{options.tenant_id}/oauth2/authorize"
36
+ options.client_options.token_url = "#{options.base_azure_url}/#{options.tenant_id}/oauth2/token"
35
37
 
36
38
  options.token_params.resource = options.resource
37
39
  super
@@ -64,6 +64,46 @@ describe OmniAuth::Strategies::AzureOauth2 do
64
64
 
65
65
  end
66
66
 
67
+ describe 'static configuration - german' do
68
+ let(:options) { @options || {} }
69
+ subject do
70
+ OmniAuth::Strategies::AzureOauth2.new(app, {client_id: 'id', client_secret: 'secret', tenant_id: 'tenant', base_azure_url: 'https://login.microsoftonline.de'}.merge(options))
71
+ end
72
+
73
+ describe '#client' do
74
+ it 'has correct authorize url' do
75
+ allow(subject).to receive(:request) { request }
76
+ expect(subject.client.options[:authorize_url]).to eql('https://login.microsoftonline.de/tenant/oauth2/authorize')
77
+ end
78
+
79
+ it 'has correct authorize params' do
80
+ allow(subject).to receive(:request) { request }
81
+ subject.client
82
+ expect(subject.authorize_params[:domain_hint]).to be_nil
83
+ end
84
+
85
+ it 'has correct token url' do
86
+ allow(subject).to receive(:request) { request }
87
+ expect(subject.client.options[:token_url]).to eql('https://login.microsoftonline.de/tenant/oauth2/token')
88
+ end
89
+
90
+ it 'has correct token params' do
91
+ allow(subject).to receive(:request) { request }
92
+ subject.client
93
+ expect(subject.token_params[:resource]).to eql('00000002-0000-0000-c000-000000000000')
94
+ end
95
+
96
+ describe "overrides" do
97
+ it 'should override domain_hint' do
98
+ @options = {domain_hint: 'hint'}
99
+ allow(subject).to receive(:request) { request }
100
+ subject.client
101
+ expect(subject.authorize_params[:domain_hint]).to eql('hint')
102
+ end
103
+ end
104
+ end
105
+ end
106
+
67
107
  describe 'static common configuration' do
68
108
  let(:options) { @options || {} }
69
109
  subject do
@@ -145,6 +185,69 @@ describe OmniAuth::Strategies::AzureOauth2 do
145
185
 
146
186
  end
147
187
 
188
+ describe 'dynamic configuration - german' do
189
+ let(:provider_klass) {
190
+ Class.new {
191
+ def initialize(strategy)
192
+ end
193
+
194
+ def client_id
195
+ 'id'
196
+ end
197
+
198
+ def client_secret
199
+ 'secret'
200
+ end
201
+
202
+ def tenant_id
203
+ 'tenant'
204
+ end
205
+
206
+ def base_azure_url
207
+ 'https://login.microsoftonline.de'
208
+ end
209
+ }
210
+ }
211
+
212
+ subject do
213
+ OmniAuth::Strategies::AzureOauth2.new(app, provider_klass)
214
+ end
215
+
216
+ before do
217
+ allow(subject).to receive(:request) { request }
218
+ end
219
+
220
+ describe '#client' do
221
+ it 'has correct authorize url' do
222
+ expect(subject.client.options[:authorize_url]).to eql('https://login.microsoftonline.de/tenant/oauth2/authorize')
223
+ end
224
+
225
+ it 'has correct authorize params' do
226
+ subject.client
227
+ expect(subject.authorize_params[:domain_hint]).to be_nil
228
+ end
229
+
230
+ it 'has correct token url' do
231
+ expect(subject.client.options[:token_url]).to eql('https://login.microsoftonline.de/tenant/oauth2/token')
232
+ end
233
+
234
+ it 'has correct token params' do
235
+ subject.client
236
+ expect(subject.token_params[:resource]).to eql('00000002-0000-0000-c000-000000000000')
237
+ end
238
+
239
+ # todo: how to get this working?
240
+ # describe "overrides" do
241
+ # it 'should override domain_hint' do
242
+ # provider_klass.domain_hint = 'hint'
243
+ # subject.client
244
+ # expect(subject.authorize_params[:domain_hint]).to eql('hint')
245
+ # end
246
+ # end
247
+ end
248
+
249
+ end
250
+
148
251
  describe 'dynamic common configuration' do
149
252
  let(:provider_klass) {
150
253
  Class.new {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-azure-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Nadig
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-08 00:00:00.000000000 Z
11
+ date: 2017-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth