workos 0.10.2 → 0.10.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84def52db9a12c4c5563af30a992f43e68441e7139624b787c588f39827d4843
4
- data.tar.gz: 1d378bfefbdeae33688496031448bac6eea97a96e1179e91496c8f8ba69c87ca
3
+ metadata.gz: 10533ea551520a47120ae8d73f4ff1399fd095eb893bd998ba200019262fc67a
4
+ data.tar.gz: 1b3bdac8336b2ee2c24a09334aecd399a897e983c6693d73dbed5f196ec3eb18
5
5
  SHA512:
6
- metadata.gz: 37117a2ea0851f35e83bbe4f17cf04dfb4ab2c7769e7f797ddd3e3d910849e0ae58e07647a72c7a21b4cf7f31f60a17fe60f78da149a422c9c211db284bc19f2
7
- data.tar.gz: 5747ba824f3aceda49c56ae5154264d153f59befd01f89465df6bb6f1e29b14edd04c9cc2f66f73442e4e31fa2766bed76ce705c4c1b4609c4b6da1bbc8f701b
6
+ metadata.gz: 0e36af027698d1887819dd51f93921eed30b47af78deabc99e34864374d5f6ff3569920cf1fdd15c26b488bdb9d7d22105e5ee89dfd40b8f0f2146e789c4b884
7
+ data.tar.gz: fb776485526b8ace124319050a709fe044fd2a2cdbdaeb261b8b92fcfb7cafdc0f31b3f913d96839671d9fee9ed5151370868b4ccd02827523fb44d478f5b4d4
data/.rubocop.yml CHANGED
@@ -13,7 +13,7 @@ Metrics/BlockLength:
13
13
  Metrics/MethodLength:
14
14
  Max: 15
15
15
  Metrics/ModuleLength:
16
- Max: 150
16
+ Max: 200
17
17
  Metrics/ParameterLists:
18
18
  Max: 6
19
19
  Style/TrailingCommaInArguments:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- workos (0.10.2)
4
+ workos (0.10.3)
5
5
  sorbet-runtime (~> 0.5)
6
6
 
7
7
  GEM
@@ -54,7 +54,7 @@ GEM
54
54
  simplecov-html (0.12.2)
55
55
  sorbet (0.5.5560)
56
56
  sorbet-static (= 0.5.5560)
57
- sorbet-runtime (0.5.6317)
57
+ sorbet-runtime (0.5.6366)
58
58
  sorbet-static (0.5.5560-universal-darwin-14)
59
59
  unicode-display_width (1.6.0)
60
60
  vcr (5.0.0)
data/lib/workos/sso.rb CHANGED
@@ -26,6 +26,8 @@ module WorkOS
26
26
  # required
27
27
  # @param [String] provider A provider name for an Identity Provider
28
28
  # configured on your WorkOS dashboard. Only 'Google' is supported.
29
+ # @param [String] connection The ID for a Connection configured on
30
+ # WorkOS.
29
31
  # @param [String] client_id The WorkOS client ID for the environment
30
32
  # where you've configured your SSO connection.
31
33
  # @param [String] project_id The WorkOS project ID for the project.
@@ -58,15 +60,18 @@ module WorkOS
58
60
  client_id: T.nilable(String),
59
61
  domain: T.nilable(String),
60
62
  provider: T.nilable(String),
63
+ connection: T.nilable(String),
61
64
  state: T.nilable(String),
62
65
  ).returns(String)
63
66
  end
67
+ # rubocop:disable Metrics/MethodLength, Metrics/ParameterLists
64
68
  def authorization_url(
65
69
  redirect_uri:,
66
70
  project_id: nil,
67
71
  client_id: nil,
68
72
  domain: nil,
69
73
  provider: nil,
74
+ connection: nil,
70
75
  state: ''
71
76
  )
72
77
  if project_id
@@ -75,7 +80,11 @@ module WorkOS
75
80
  client_id = project_id
76
81
  end
77
82
 
78
- validate_domain_and_provider(provider: provider, domain: domain)
83
+ validate_authorization_url_arguments(
84
+ provider: provider,
85
+ domain: domain,
86
+ connection: connection,
87
+ )
79
88
 
80
89
  query = URI.encode_www_form({
81
90
  client_id: client_id,
@@ -84,10 +93,12 @@ module WorkOS
84
93
  state: state,
85
94
  domain: domain,
86
95
  provider: provider,
96
+ connection: connection,
87
97
  }.compact)
88
98
 
89
99
  "https://#{WorkOS::API_HOSTNAME}/sso/authorize?#{query}"
90
100
  end
101
+ # rubocop:enable Metrics/MethodLength, Metrics/ParameterLists
91
102
 
92
103
  # Fetch the profile details for the authenticated SSO user.
93
104
  #
@@ -284,11 +295,17 @@ module WorkOS
284
295
  params(
285
296
  domain: T.nilable(String),
286
297
  provider: T.nilable(String),
298
+ connection: T.nilable(String),
287
299
  ).void
288
300
  end
289
- def validate_domain_and_provider(domain:, provider:)
290
- if [domain, provider].all?(&:nil?)
291
- raise ArgumentError, 'Either domain or provider is required.'
301
+ def validate_authorization_url_arguments(
302
+ domain:,
303
+ provider:,
304
+ connection:
305
+ )
306
+ if [domain, provider, connection].all?(&:nil?)
307
+ raise ArgumentError, 'Either connection, domain, or ' \
308
+ 'provider is required.'
292
309
  end
293
310
 
294
311
  return unless provider && !PROVIDERS.include?(provider)
@@ -2,5 +2,5 @@
2
2
  # typed: strong
3
3
 
4
4
  module WorkOS
5
- VERSION = '0.10.2'
5
+ VERSION = '0.10.3'
6
6
  end
@@ -2,14 +2,6 @@
2
2
  # typed: false
3
3
 
4
4
  describe WorkOS::AuditTrail do
5
- before(:all) do
6
- WorkOS.key = 'key'
7
- end
8
-
9
- after(:all) do
10
- WorkOS.key = nil
11
- end
12
-
13
5
  describe '.create_event' do
14
6
  context 'with valid event payload' do
15
7
  let(:valid_event) do
@@ -2,14 +2,6 @@
2
2
  # typed: false
3
3
 
4
4
  describe WorkOS::DirectorySync do
5
- before(:all) do
6
- WorkOS.key = 'key'
7
- end
8
-
9
- after(:all) do
10
- WorkOS.key = nil
11
- end
12
-
13
5
  describe '.list_directories' do
14
6
  context 'with no options' do
15
7
  it 'returns directories' do
@@ -2,14 +2,6 @@
2
2
  # typed: false
3
3
 
4
4
  describe WorkOS::Passwordless do
5
- before(:all) do
6
- WorkOS.key = 'key'
7
- end
8
-
9
- after(:all) do
10
- WorkOS.key = nil
11
- end
12
-
13
5
  describe '.create_session' do
14
6
  context 'with valid options payload' do
15
7
  let(:valid_options) do
@@ -2,14 +2,6 @@
2
2
  # typed: false
3
3
 
4
4
  describe WorkOS::Portal do
5
- before :all do
6
- WorkOS.key = 'test'
7
- end
8
-
9
- after :all do
10
- WorkOS.key = nil
11
- end
12
-
13
5
  describe '.create_organization' do
14
6
  context 'with valid payload' do
15
7
  it 'creates an organization' do
@@ -73,7 +73,41 @@ describe WorkOS::SSO do
73
73
  end
74
74
  end
75
75
 
76
- context 'with neither domain or provider' do
76
+ context 'with a connection' do
77
+ let(:args) do
78
+ {
79
+ connection: 'connection_123',
80
+ client_id: 'workos-proj-123',
81
+ redirect_uri: 'foo.com/auth/callback',
82
+ state: {
83
+ next_page: '/dashboard/edit',
84
+ }.to_s,
85
+ }
86
+ end
87
+ it 'returns a valid URL' do
88
+ authorization_url = described_class.authorization_url(**args)
89
+
90
+ expect(URI.parse(authorization_url)).to be_a URI
91
+ end
92
+
93
+ it 'returns the expected hostname' do
94
+ authorization_url = described_class.authorization_url(**args)
95
+
96
+ expect(URI.parse(authorization_url).host).to eq(WorkOS::API_HOSTNAME)
97
+ end
98
+
99
+ it 'returns the expected query string' do
100
+ authorization_url = described_class.authorization_url(**args)
101
+
102
+ expect(URI.parse(authorization_url).query).to eq(
103
+ 'client_id=workos-proj-123&redirect_uri=foo.com%2Fauth%2Fcallback' \
104
+ '&response_type=code&state=%7B%3Anext_page%3D%3E%22%2Fdashboard%2F' \
105
+ 'edit%22%7D&connection=connection_123',
106
+ )
107
+ end
108
+ end
109
+
110
+ context 'with neither connection, domain, or provider' do
77
111
  let(:args) do
78
112
  {
79
113
  client_id: 'workos-proj-123',
@@ -88,7 +122,7 @@ describe WorkOS::SSO do
88
122
  described_class.authorization_url(**args)
89
123
  end.to raise_error(
90
124
  ArgumentError,
91
- 'Either domain or provider is required.',
125
+ 'Either connection, domain, or provider is required.',
92
126
  )
93
127
  end
94
128
  end
@@ -159,10 +193,6 @@ describe WorkOS::SSO do
159
193
  end
160
194
 
161
195
  describe '.profile' do
162
- before do
163
- WorkOS.key = 'api-key'
164
- end
165
-
166
196
  let(:args) do
167
197
  {
168
198
  code: SecureRandom.hex(10),
@@ -274,14 +304,6 @@ describe WorkOS::SSO do
274
304
  end
275
305
 
276
306
  describe '.create_connection' do
277
- before(:all) do
278
- WorkOS.key = 'key'
279
- end
280
-
281
- after(:all) do
282
- WorkOS.key = nil
283
- end
284
-
285
307
  context 'with a valid source' do
286
308
  it 'creates a connection' do
287
309
  VCR.use_cassette('sso/create_connection_with_valid_source') do
@@ -312,14 +334,6 @@ describe WorkOS::SSO do
312
334
  end
313
335
 
314
336
  describe '.promote_draft_connection' do
315
- before(:all) do
316
- WorkOS.key = 'key'
317
- end
318
-
319
- after(:all) do
320
- WorkOS.key = nil
321
- end
322
-
323
337
  let(:token) { 'draft_conn_id' }
324
338
  let(:client_id) { 'proj_0239u590h' }
325
339
 
@@ -357,14 +371,6 @@ describe WorkOS::SSO do
357
371
  end
358
372
 
359
373
  describe '.list_connections' do
360
- before(:all) do
361
- WorkOS.key = 'key'
362
- end
363
-
364
- after(:all) do
365
- WorkOS.key = nil
366
- end
367
-
368
374
  context 'with no options' do
369
375
  it 'returns connections' do
370
376
  VCR.use_cassette('sso/list_connections') do
@@ -446,14 +452,6 @@ describe WorkOS::SSO do
446
452
  end
447
453
 
448
454
  describe '.get_connection' do
449
- before(:all) do
450
- WorkOS.key = 'key'
451
- end
452
-
453
- after(:all) do
454
- WorkOS.key = nil
455
- end
456
-
457
455
  context 'with a valid id' do
458
456
  it 'gets the connection details' do
459
457
  VCR.use_cassette('sso/get_connection_with_valid_id') do
@@ -484,14 +482,6 @@ describe WorkOS::SSO do
484
482
  end
485
483
 
486
484
  describe '.delete_connection' do
487
- before(:all) do
488
- WorkOS.key = 'key'
489
- end
490
-
491
- after(:all) do
492
- WorkOS.key = nil
493
- end
494
-
495
485
  context 'with a valid id' do
496
486
  it 'returns true' do
497
487
  VCR.use_cassette('sso/delete_connection_with_valid_id') do
data/spec/spec_helper.rb CHANGED
@@ -48,5 +48,6 @@ RSpec.configure do |config|
48
48
  end
49
49
  end)
50
50
 
51
+ config.before(:all) { WorkOS.key ||= '' }
51
52
  config.before(:each) { VCR.turn_on! }
52
53
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.2
4
+ version: 0.10.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - WorkOS
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-03 00:00:00.000000000 Z
11
+ date: 2021-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sorbet-runtime
@@ -305,7 +305,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
305
305
  - !ruby/object:Gem::Version
306
306
  version: '0'
307
307
  requirements: []
308
- rubygems_version: 3.2.13
308
+ rubygems_version: 3.2.15
309
309
  signing_key:
310
310
  specification_version: 4
311
311
  summary: API client for WorkOS