workos 4.0.0 → 4.1.0

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: 301b7f9d339c1ec1bf85dfc43a4d1ba85de8b6234323c8982fa2f2cf76bed6dd
4
- data.tar.gz: 91ed96c899e42ccaed1955304fd98a7da7ca7e946be803df4e7c27f4cb3db5fc
3
+ metadata.gz: '0828780b58051c7e4da7d76717a9eb71209803a508c71ca287a99dabcb0cc55a'
4
+ data.tar.gz: 5da4147318e6c1f9947b50f69e8bf37dfbed7fd936deda7c46c9a072abfed99f
5
5
  SHA512:
6
- metadata.gz: b96feaf7d73165f33b979f3cd396adcf91aa4457161647b57423bf204bd89de42e6badeba37f06faf562bd58f5148fe9bd329850721c1efe5f0d0d18e0459bf6
7
- data.tar.gz: 9417023f79e961c063fcb17c4ca60035e292fe2c321710778d99610165bea2b5c564e7dfad24a7b2effdb51b0d5355fe0c4155de45c7ef5d0d073ddfbbb1f1c6
6
+ metadata.gz: '0916ae54fc3f1e30edf8f03dab9a75382062122a5b554aeefbaea26b39edc2e4d6415a9bdda25e53f19c5b82e6bb6e5e675c7c4ba1bc971a689346e6af997935'
7
+ data.tar.gz: 232a18c18b3c58181dd3f3a16c8c8f16a9f7aa7d1dc5ac088dbda986b9fd86347fe41def6a27d3d19ca7ff2867f03353daefa611c6df175ad5b9464539cadfff
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- workos (4.0.0)
4
+ workos (4.1.0)
5
5
  sorbet-runtime (~> 0.5)
6
6
 
7
7
  GEM
@@ -8,19 +8,29 @@ module WorkOS
8
8
  include HashProvider
9
9
  extend T::Sig
10
10
 
11
- attr_accessor :user, :organization_id
11
+ attr_accessor :user, :organization_id, :impersonator, :access_token, :refresh_token
12
12
 
13
13
  sig { params(authentication_response_json: String).void }
14
14
  def initialize(authentication_response_json)
15
15
  json = JSON.parse(authentication_response_json, symbolize_names: true)
16
16
  @user = WorkOS::User.new(json[:user].to_json)
17
17
  @organization_id = T.let(json[:organization_id], T.nilable(String))
18
+ @impersonator =
19
+ if (impersonator_json = json[:impersonator])
20
+ Impersonator.new(email: impersonator_json[:email],
21
+ reason: impersonator_json[:reason],)
22
+ end
23
+ @access_token = T.let(json[:access_token], String)
24
+ @refresh_token = T.let(json[:refresh_token], String)
18
25
  end
19
26
 
20
27
  def to_json(*)
21
28
  {
22
29
  user: user.to_json,
23
30
  organization_id: organization_id,
31
+ impersonator: impersonator.to_json,
32
+ access_token: access_token,
33
+ refresh_token: refresh_token,
24
34
  }
25
35
  end
26
36
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+ # typed: true
3
+
4
+ module WorkOS
5
+ # Contains information about a WorkOS Dashboard user impersonating
6
+ # a User Management user.
7
+ class Impersonator
8
+ include HashProvider
9
+ extend T::Sig
10
+
11
+ attr_accessor :email, :reason
12
+
13
+ sig { params(email: String, reason: T.nilable(String)).void }
14
+ def initialize(email:, reason:)
15
+ @email = email
16
+ @reason = reason
17
+ end
18
+
19
+ def to_json(*)
20
+ {
21
+ email: email,
22
+ reason: reason,
23
+ }
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+ # typed: true
3
+
4
+ module WorkOS
5
+ # The RefreshAuthenticationResponse contains response data from a successful
6
+ # `UserManagement.authenticate_with_refresh_token` call
7
+ class RefreshAuthenticationResponse
8
+ include HashProvider
9
+ extend T::Sig
10
+
11
+ attr_accessor :access_token, :refresh_token
12
+
13
+ sig { params(authentication_response_json: String).void }
14
+ def initialize(authentication_response_json)
15
+ json = JSON.parse(authentication_response_json, symbolize_names: true)
16
+ @access_token = T.let(json[:access_token], String)
17
+ @refresh_token = T.let(json[:refresh_token], String)
18
+ end
19
+
20
+ def to_json(*)
21
+ {
22
+ access_token: access_token,
23
+ refresh_token: refresh_token,
24
+ }
25
+ end
26
+ end
27
+ end
@@ -366,6 +366,46 @@ module WorkOS
366
366
  WorkOS::AuthenticationResponse.new(response.body)
367
367
  end
368
368
 
369
+ # Authenticate a user using a refresh token.
370
+ #
371
+ # @param [String] refresh_token The refresh token previously obtained from a successful authentication call
372
+ # @param [String] client_id The WorkOS client ID for the environment
373
+ # @param [String] ip_address The IP address of the request from the user who is attempting to authenticate.
374
+ # @param [String] user_agent The user agent of the request from the user who is attempting to authenticate.
375
+ #
376
+ # @return WorkOS::RefreshAuthenticationResponse
377
+
378
+ sig do
379
+ params(
380
+ refresh_token: String,
381
+ client_id: String,
382
+ ip_address: T.nilable(String),
383
+ user_agent: T.nilable(String),
384
+ ).returns(WorkOS::RefreshAuthenticationResponse)
385
+ end
386
+ def authenticate_with_refresh_token(
387
+ refresh_token:,
388
+ client_id:,
389
+ ip_address: nil,
390
+ user_agent: nil
391
+ )
392
+ response = execute_request(
393
+ request: post_request(
394
+ path: '/user_management/authenticate',
395
+ body: {
396
+ refresh_token: refresh_token,
397
+ client_id: client_id,
398
+ client_secret: WorkOS.config.key!,
399
+ ip_address: ip_address,
400
+ user_agent: user_agent,
401
+ grant_type: 'refresh_token',
402
+ },
403
+ ),
404
+ )
405
+
406
+ WorkOS::RefreshAuthenticationResponse.new(response.body)
407
+ end
408
+
369
409
  # Authenticate user by Magic Auth Code.
370
410
  #
371
411
  # @param [String] code The one-time code that was emailed to the user.
@@ -554,6 +594,66 @@ module WorkOS
554
594
  WorkOS::AuthenticationResponse.new(response.body)
555
595
  end
556
596
 
597
+ # Get the logout URL for a session
598
+ #
599
+ # The user's browser should be navigated to this URL
600
+ #
601
+ # @param [String] session_id The session ID can be found in the `sid`
602
+ # claim of the access token
603
+ #
604
+ # @return String
605
+ sig do
606
+ params(
607
+ session_id: String,
608
+ ).returns(String)
609
+ end
610
+ def get_logout_url(session_id:)
611
+ URI::HTTPS.build(
612
+ host: WorkOS.config.api_hostname,
613
+ path: '/user_management/sessions/logout',
614
+ query: "session_id=#{session_id}",
615
+ ).to_s
616
+ end
617
+
618
+ # Revokes a session
619
+ #
620
+ # @param [String] session_id The session ID can be found in the `sid`
621
+ # claim of the access token
622
+ sig do
623
+ params(
624
+ session_id: String,
625
+ ).void
626
+ end
627
+ def revoke_session(session_id:)
628
+ execute_request(
629
+ request: post_request(
630
+ path: '/user_management/sessions/revoke',
631
+ body: {
632
+ session_id: session_id,
633
+ },
634
+ ),
635
+ )
636
+ end
637
+
638
+ # Get the JWKS URL
639
+ #
640
+ # The JWKS can be used to validate the access token returned upon successful authentication
641
+ #
642
+ # @param [String] client_id The WorkOS client ID for the environment
643
+ #
644
+ # @return String
645
+ sig do
646
+ params(
647
+ client_id: String,
648
+ ).returns(String)
649
+ end
650
+ def get_jwks_url(client_id)
651
+ URI::HTTPS.build(
652
+ host: WorkOS.config.api_hostname,
653
+ path: "/sso/jwks/#{client_id}",
654
+ ).to_s
655
+ end
656
+
557
657
  # Create a one-time Magic Auth code and emails it to the user.
558
658
  #
559
659
  # @param [String] email The email address the one-time code will be sent to.
@@ -2,5 +2,5 @@
2
2
  # typed: strong
3
3
 
4
4
  module WorkOS
5
- VERSION = '4.0.0'
5
+ VERSION = '4.1.0'
6
6
  end
data/lib/workos.rb CHANGED
@@ -58,6 +58,7 @@ module WorkOS
58
58
  autoload :Event, 'workos/event'
59
59
  autoload :Events, 'workos/events'
60
60
  autoload :Factor, 'workos/factor'
61
+ autoload :Impersonator, 'workos/impersonator'
61
62
  autoload :Invitation, 'workos/invitation'
62
63
  autoload :MFA, 'workos/mfa'
63
64
  autoload :Organization, 'workos/organization'
@@ -67,6 +68,7 @@ module WorkOS
67
68
  autoload :Portal, 'workos/portal'
68
69
  autoload :Profile, 'workos/profile'
69
70
  autoload :ProfileAndToken, 'workos/profile_and_token'
71
+ autoload :RefreshAuthenticationResponse, 'workos/refresh_authentication_response'
70
72
  autoload :SSO, 'workos/sso'
71
73
  autoload :Types, 'workos/types'
72
74
  autoload :User, 'workos/user'
@@ -377,7 +377,7 @@ describe WorkOS::UserManagement do
377
377
  describe '.authenticate_with_password' do
378
378
  context 'with a valid password' do
379
379
  it 'returns user' do
380
- VCR.use_cassette('user_management/authenticate_with_password/valid') do
380
+ VCR.use_cassette('user_management/authenticate_with_password/valid', tag: :token) do
381
381
  authentication_response = WorkOS::UserManagement.authenticate_with_password(
382
382
  email: 'test@workos.app',
383
383
  password: '7YtYic00VWcXatPb',
@@ -418,6 +418,24 @@ describe WorkOS::UserManagement do
418
418
  user_agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) Chrome/108.0.0.0 Safari/537.36',
419
419
  )
420
420
  expect(authentication_response.user.id).to eq('user_01H93ZY4F80YZRRS6N59Z2HFVS')
421
+ expect(authentication_response.access_token).to eq('<ACCESS_TOKEN>')
422
+ expect(authentication_response.refresh_token).to eq('<REFRESH_TOKEN>')
423
+ end
424
+ end
425
+
426
+ context 'when the user is being impersonated' do
427
+ it 'contains the impersonator metadata' do
428
+ VCR.use_cassette('user_management/authenticate_with_code/valid_with_impersonator') do
429
+ authentication_response = WorkOS::UserManagement.authenticate_with_code(
430
+ code: '01HRX85ATQB2MN40K4FZ9C2HFR',
431
+ client_id: 'client_01GS91XFB2YPR1C0NR5SH758Q0',
432
+ )
433
+
434
+ expect(authentication_response.impersonator).to have_attributes(
435
+ email: 'admin@foocorp.com',
436
+ reason: 'For testing.',
437
+ )
438
+ end
421
439
  end
422
440
  end
423
441
  end
@@ -438,10 +456,42 @@ describe WorkOS::UserManagement do
438
456
  end
439
457
  end
440
458
 
459
+ describe '.authenticate_with_refresh_token' do
460
+ context 'with a valid refresh_token' do
461
+ it 'returns user' do
462
+ VCR.use_cassette('user_management/authenticate_with_refresh_token/valid', tag: :token) do
463
+ authentication_response = WorkOS::UserManagement.authenticate_with_refresh_token(
464
+ refresh_token: 'some_refresh_token',
465
+ client_id: 'client_123',
466
+ ip_address: '200.240.210.16',
467
+ user_agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) Chrome/108.0.0.0 Safari/537.36',
468
+ )
469
+ expect(authentication_response.access_token).to eq('<ACCESS_TOKEN>')
470
+ expect(authentication_response.refresh_token).to eq('<REFRESH_TOKEN>')
471
+ end
472
+ end
473
+ end
474
+
475
+ context 'with an invalid refresh_token' do
476
+ it 'raises an error' do
477
+ VCR.use_cassette('user_management/authenticate_with_refresh_code/invalid', tag: :token) do
478
+ expect do
479
+ WorkOS::UserManagement.authenticate_with_refresh_token(
480
+ refresh_token: 'invalid',
481
+ client_id: 'client_123',
482
+ ip_address: '200.240.210.16',
483
+ user_agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) Chrome/108.0.0.0 Safari/537.36',
484
+ )
485
+ end.to raise_error(WorkOS::InvalidRequestError, /Status 400/)
486
+ end
487
+ end
488
+ end
489
+ end
490
+
441
491
  describe '.authenticate_with_magic_auth' do
442
492
  context 'with a valid code' do
443
493
  it 'returns user' do
444
- VCR.use_cassette('user_management/authenticate_with_magic_auth/valid') do
494
+ VCR.use_cassette('user_management/authenticate_with_magic_auth/valid', tag: :token) do
445
495
  authentication_response = WorkOS::UserManagement.authenticate_with_magic_auth(
446
496
  code: '452079',
447
497
  client_id: 'project_01EGKAEB7G5N88E83MF99J785F',
@@ -456,7 +506,7 @@ describe WorkOS::UserManagement do
456
506
 
457
507
  context 'with an invalid code' do
458
508
  it 'returns an error' do
459
- VCR.use_cassette('user_management/authenticate_with_magic_auth/invalid') do
509
+ VCR.use_cassette('user_management/authenticate_with_magic_auth/invalid', tag: :token) do
460
510
  expect do
461
511
  WorkOS::UserManagement.authenticate_with_magic_auth(
462
512
  code: 'invalid',
@@ -472,7 +522,7 @@ describe WorkOS::UserManagement do
472
522
  describe '.authenticate_with_organization_selection' do
473
523
  context 'with a valid code' do
474
524
  it 'returns user' do
475
- VCR.use_cassette('user_management/authenticate_with_organization_selection/valid') do
525
+ VCR.use_cassette('user_management/authenticate_with_organization_selection/valid', tag: :token) do
476
526
  authentication_response = WorkOS::UserManagement.authenticate_with_organization_selection(
477
527
  client_id: 'project_01EGKAEB7G5N88E83MF99J785F',
478
528
  organization_id: 'org_01H5JQDV7R7ATEYZDEG0W5PRYS',
@@ -488,7 +538,7 @@ describe WorkOS::UserManagement do
488
538
 
489
539
  context 'with an invalid token' do
490
540
  it 'returns an error' do
491
- VCR.use_cassette('user_management/authenticate_with_organization_selection/invalid') do
541
+ VCR.use_cassette('user_management/authenticate_with_organization_selection/invalid', tag: :token) do
492
542
  expect do
493
543
  WorkOS::UserManagement.authenticate_with_organization_selection(
494
544
  organization_id: 'invalid_org_id',
@@ -504,7 +554,7 @@ describe WorkOS::UserManagement do
504
554
  describe '.authenticate_with_totp' do
505
555
  context 'with a valid code' do
506
556
  it 'returns user' do
507
- VCR.use_cassette('user_management/authenticate_with_totp/valid') do
557
+ VCR.use_cassette('user_management/authenticate_with_totp/valid', tag: :token) do
508
558
  authentication_response = WorkOS::UserManagement.authenticate_with_totp(
509
559
  code: '01H93ZZHA0JBHFJH9RR11S83YN',
510
560
  client_id: 'client_123',
@@ -520,7 +570,7 @@ describe WorkOS::UserManagement do
520
570
 
521
571
  context 'with an invalid code' do
522
572
  it 'raises an error' do
523
- VCR.use_cassette('user_management/authenticate_with_totp/invalid') do
573
+ VCR.use_cassette('user_management/authenticate_with_totp/invalid', tag: :token) do
524
574
  expect do
525
575
  WorkOS::UserManagement.authenticate_with_totp(
526
576
  code: 'invalid',
@@ -539,7 +589,7 @@ describe WorkOS::UserManagement do
539
589
  describe '.authenticate_with_email_verification' do
540
590
  context 'with a valid code' do
541
591
  it 'returns user' do
542
- VCR.use_cassette('user_management/authenticate_with_email_verification/valid') do
592
+ VCR.use_cassette('user_management/authenticate_with_email_verification/valid', tag: :token) do
543
593
  authentication_response = WorkOS::UserManagement.authenticate_with_email_verification(
544
594
  code: '01H93ZZHA0JBHFJH9RR11S83YN',
545
595
  client_id: 'client_123',
@@ -554,7 +604,7 @@ describe WorkOS::UserManagement do
554
604
 
555
605
  context 'with an invalid code' do
556
606
  it 'raises an error' do
557
- VCR.use_cassette('user_management/authenticate_with_email_verification/invalid') do
607
+ VCR.use_cassette('user_management/authenticate_with_email_verification/invalid', tag: :token) do
558
608
  expect do
559
609
  WorkOS::UserManagement.authenticate_with_email_verification(
560
610
  code: 'invalid',
data/spec/spec_helper.rb CHANGED
@@ -26,6 +26,12 @@ SPEC_ROOT = File.dirname __FILE__
26
26
  VCR.configure do |config|
27
27
  config.cassette_library_dir = 'spec/support/fixtures/vcr_cassettes'
28
28
  config.filter_sensitive_data('<API_KEY>') { WorkOS.config.key }
29
+ config.filter_sensitive_data('<ACCESS_TOKEN>', :token) do |interaction|
30
+ JSON.parse(interaction.response.body)['access_token']
31
+ end
32
+ config.filter_sensitive_data('<REFRESH_TOKEN>', :token) do |interaction|
33
+ JSON.parse(interaction.response.body)['refresh_token']
34
+ end
29
35
  config.hook_into :webmock
30
36
  end
31
37
 
@@ -76,7 +76,7 @@ http_interactions:
76
76
  - cloudflare
77
77
  body:
78
78
  encoding: ASCII-8BIT
79
- string: '{"user":{"object":"user","id":"user_01H93ZY4F80YZRRS6N59Z2HFVS","email":"test@workos.app","email_verified":false,"first_name":"Lucille","last_name":"Bluth","created_at":"2023-08-30T19:50:13.214Z","updated_at":"2023-08-30T19:50:13.214Z","user_type":"managed","sso_profile_id":"prof_01H93ZTVWYPAT4RKDSPFPPXH0J"}}'
79
+ string: '{"user":{"object":"user","id":"user_01H93ZY4F80YZRRS6N59Z2HFVS","email":"test@workos.app","email_verified":false,"first_name":"Lucille","last_name":"Bluth","created_at":"2023-08-30T19:50:13.214Z","updated_at":"2023-08-30T19:50:13.214Z","user_type":"managed","sso_profile_id":"prof_01H93ZTVWYPAT4RKDSPFPPXH0J"},"access_token":"<ACCESS_TOKEN>","refresh_token":"<REFRESH_TOKEN>"}'
80
80
  http_version:
81
81
  recorded_at: Wed, 30 Aug 2023 19:51:51 GMT
82
82
  recorded_with: VCR 5.0.0
@@ -0,0 +1,80 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.workos.com/user_management/authenticate
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"code":"01HRX85ATQB2MN40K4FZ9C2HFR","client_id":"client_01GS91XFB2YPR1C0NR5SH758Q0","client_secret":"<API_KEY>","ip_address":null,"user_agent":null,"grant_type":"authorization_code"}'
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ User-Agent:
17
+ - WorkOS; ruby/3.1.1; arm64-darwin21; v4.0.0
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Date:
24
+ - Thu, 14 Mar 2024 01:10:34 GMT
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Content-Length:
28
+ - '875'
29
+ Connection:
30
+ - keep-alive
31
+ Cf-Ray:
32
+ - 8640628169fa0d54-LAX
33
+ Cf-Cache-Status:
34
+ - DYNAMIC
35
+ Etag:
36
+ - W/"47c-66YSPNMN47PZx4ahCgTQvmryR90"
37
+ Strict-Transport-Security:
38
+ - max-age=15552000; includeSubDomains
39
+ Vary:
40
+ - Origin, Accept-Encoding
41
+ Via:
42
+ - 1.1 spaces-router (devel)
43
+ Access-Control-Allow-Credentials:
44
+ - 'true'
45
+ Content-Security-Policy:
46
+ - 'default-src ''self'';base-uri ''self'';block-all-mixed-content;font-src ''self''
47
+ https: data:;frame-ancestors ''self'';img-src ''self'' data:;object-src ''none'';script-src
48
+ ''self'';script-src-attr ''none'';style-src ''self'' https: ''unsafe-inline'';upgrade-insecure-requests'
49
+ Expect-Ct:
50
+ - max-age=0
51
+ Referrer-Policy:
52
+ - no-referrer
53
+ X-Content-Type-Options:
54
+ - nosniff
55
+ X-Dns-Prefetch-Control:
56
+ - 'off'
57
+ X-Download-Options:
58
+ - noopen
59
+ X-Frame-Options:
60
+ - SAMEORIGIN
61
+ X-Permitted-Cross-Domain-Policies:
62
+ - none
63
+ X-Request-Id:
64
+ - f22ea52f-bf1a-4d5e-acb1-10b2e99ffbe5
65
+ X-Xss-Protection:
66
+ - '0'
67
+ Set-Cookie:
68
+ - __cf_bm=pYiV6zsrN3V8vd8vKA_bp0qN2LYd1HUQAIVHcevLYw4-1710378634-1.0.1.1-wNPVRK6jpySHc7bqiAVCtM6T64oKxFAjrcvJNJAPU.RhZFRgPfQRGWYbC4l0ckcsyhZ2_I7GTu17yNowC.smHA;
69
+ path=/; expires=Thu, 14-Mar-24 01:40:34 GMT; domain=.workos.com; HttpOnly;
70
+ Secure; SameSite=None
71
+ - __cfruid=914cc38ede83520e897d1eaef25a8e5daa4975d0-1710378634; path=/; domain=.workos.com;
72
+ HttpOnly; Secure; SameSite=None
73
+ Server:
74
+ - cloudflare
75
+ body:
76
+ encoding: ASCII-8BIT
77
+ string: '{"user":{"object":"user","id":"user_01HP0B4ZV2FWWVY0BF16GFDAER","email":"bob@example.com","email_verified":false,"first_name":"Bob","last_name":"Loblaw","profile_picture_url":null,"created_at":"2024-02-06T23:13:18.137Z","updated_at":"2024-02-06T23:13:36.946Z"},"impersonator":{"email":"admin@foocorp.com","reason":"For testing."},"access_token":"<ACCESS_TOKEN>","refresh_token":"<REFRESH_TOKEN>"}'
78
+ http_version:
79
+ recorded_at: Thu, 14 Mar 2024 01:10:34 GMT
80
+ recorded_with: VCR 5.0.0
@@ -75,7 +75,7 @@ http_interactions:
75
75
  - cloudflare
76
76
  body:
77
77
  encoding: ASCII-8BIT
78
- string: '{"user":{"object":"user","id":"user_01H93ZY4F80YZRRS6N59Z2HFVS","email":"test@workos.app","email_verified":false,"first_name":"Lucille","last_name":"Bluth","created_at":"2023-08-30T19:50:13.214Z","updated_at":"2023-08-30T19:50:13.214Z","user_type":"managed","sso_profile_id":"prof_01H93ZTVWYPAT4RKDSPFPPXH0J"}}'
78
+ string: '{"user":{"object":"user","id":"user_01H93ZY4F80YZRRS6N59Z2HFVS","email":"test@workos.app","email_verified":false,"first_name":"Lucille","last_name":"Bluth","created_at":"2023-08-30T19:50:13.214Z","updated_at":"2023-08-30T19:50:13.214Z","user_type":"managed","sso_profile_id":"prof_01H93ZTVWYPAT4RKDSPFPPXH0J"},"access_token":"<ACCESS_TOKEN>","refresh_token":"<REFRESH_TOKEN>"}'
79
79
  http_version:
80
80
  recorded_at: Wed, 30 Aug 2023 19:51:51 GMT
81
81
  recorded_with: VCR 5.0.0
@@ -76,7 +76,7 @@ http_interactions:
76
76
  - cloudflare
77
77
  body:
78
78
  encoding: ASCII-8BIT
79
- string: '{"user":{"object":"user","id":"user_01H93WD0R0KWF8Q7BK02C0RPYJ","email":"test@workos.app","email_verified":true,"first_name":"Lucille","last_name":"Bluth","created_at":"2023-08-30T18:48:26.517Z","updated_at":"2023-08-30T18:58:00.821Z","user_type":"unmanaged","email_verified_at":"2023-08-30T18:58:00.915Z","google_oauth_profile_id":null,"microsoft_oauth_profile_id":null}}'
79
+ string: '{"user":{"object":"user","id":"user_01H93WD0R0KWF8Q7BK02C0RPYJ","email":"test@workos.app","email_verified":true,"first_name":"Lucille","last_name":"Bluth","created_at":"2023-08-30T18:48:26.517Z","updated_at":"2023-08-30T18:58:00.821Z","user_type":"unmanaged","email_verified_at":"2023-08-30T18:58:00.915Z","google_oauth_profile_id":null,"microsoft_oauth_profile_id":null},"access_token":"<ACCESS_TOKEN>","refresh_token":"<REFRESH_TOKEN>"}'
80
80
  http_version:
81
81
  recorded_at: Wed, 30 Aug 2023 18:58:00 GMT
82
82
  recorded_with: VCR 5.0.0
@@ -76,7 +76,7 @@ http_interactions:
76
76
  - cloudflare
77
77
  body:
78
78
  encoding: UTF-8
79
- string: '{"organization_id":"org_01H5JQDV7R7ATEYZDEG0W5PRYS","user":{"object":"user","id":"user_01H93WD0R0KWF8Q7BK02C0RPYJ","email":"test@workos.app","email_verified":true,"first_name":"Lucille","last_name":"Bluth","created_at":"2023-08-30T18:48:26.517Z","updated_at":"2023-08-30T18:58:00.821Z","user_type":"unmanaged","email_verified_at":"2023-08-30T18:58:00.915Z","google_oauth_profile_id":null,"microsoft_oauth_profile_id":null}}'
79
+ string: '{"organization_id":"org_01H5JQDV7R7ATEYZDEG0W5PRYS","user":{"object":"user","id":"user_01H93WD0R0KWF8Q7BK02C0RPYJ","email":"test@workos.app","email_verified":true,"first_name":"Lucille","last_name":"Bluth","created_at":"2023-08-30T18:48:26.517Z","updated_at":"2023-08-30T18:58:00.821Z","user_type":"unmanaged","email_verified_at":"2023-08-30T18:58:00.915Z","google_oauth_profile_id":null,"microsoft_oauth_profile_id":null},"access_token":"<ACCESS_TOKEN>","refresh_token":"<REFRESH_TOKEN>"}'
80
80
  http_version:
81
81
  recorded_at: Wed, 20 Dec 2023 22:00:12 GMT
82
82
  recorded_with: VCR 5.0.0
@@ -76,7 +76,7 @@ http_interactions:
76
76
  - cloudflare
77
77
  body:
78
78
  encoding: ASCII-8BIT
79
- string: '{"user":{"object":"user","id":"user_01H7TVSKS45SDHN5V9XPSM6H44","email":"test@workos.app","email_verified":true,"first_name":null,"last_name":null,"created_at":"2023-08-14T20:28:58.929Z","updated_at":"2023-08-28T15:56:19.798Z","user_type":"unmanaged","email_verified_at":"2023-08-22T11:18:01.850Z","google_oauth_profile_id":null,"microsoft_oauth_profile_id":null}}'
79
+ string: '{"user":{"object":"user","id":"user_01H7TVSKS45SDHN5V9XPSM6H44","email":"test@workos.app","email_verified":true,"first_name":null,"last_name":null,"created_at":"2023-08-14T20:28:58.929Z","updated_at":"2023-08-28T15:56:19.798Z","user_type":"unmanaged","email_verified_at":"2023-08-22T11:18:01.850Z","google_oauth_profile_id":null,"microsoft_oauth_profile_id":null},"access_token":"<ACCESS_TOKEN>","refresh_token":"<REFRESH_TOKEN>"}'
80
80
  http_version:
81
81
  recorded_at: Tue, 29 Aug 2023 00:24:25 GMT
82
82
  recorded_with: VCR 5.0.0
@@ -0,0 +1,81 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.workos.com/user_management/authenticate
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"refresh_token":"invalid","client_id":"client_123","client_secret":"<API_KEY>","ip_address":"200.240.210.16","user_agent":"Mozilla/5.0
9
+ (Macintosh; Intel Mac OS X 10_15_7) Chrome/108.0.0.0 Safari/537.36","grant_type":"refresh_token"}'
10
+ headers:
11
+ Content-Type:
12
+ - application/json
13
+ Accept-Encoding:
14
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
15
+ Accept:
16
+ - "*/*"
17
+ User-Agent:
18
+ - WorkOS; ruby/3.2.2; arm64-darwin22; v4.0.0
19
+ response:
20
+ status:
21
+ code: 400
22
+ message: Bad Request
23
+ headers:
24
+ Date:
25
+ - Tue, 19 Mar 2024 16:06:37 GMT
26
+ Content-Type:
27
+ - application/json; charset=utf-8
28
+ Content-Length:
29
+ - '70'
30
+ Connection:
31
+ - keep-alive
32
+ Cf-Ray:
33
+ - 866eb5f11e5f5304-SLC
34
+ Cf-Cache-Status:
35
+ - DYNAMIC
36
+ Etag:
37
+ - W/"46-6ugkBnqF9SxNnhijAAHjGcT083A"
38
+ Strict-Transport-Security:
39
+ - max-age=15552000; includeSubDomains
40
+ Vary:
41
+ - Origin, Accept-Encoding
42
+ Via:
43
+ - 1.1 spaces-router (devel)
44
+ Access-Control-Allow-Credentials:
45
+ - 'true'
46
+ Content-Security-Policy:
47
+ - 'default-src ''self'';base-uri ''self'';block-all-mixed-content;font-src ''self''
48
+ https: data:;frame-ancestors ''self'';img-src ''self'' data:;object-src ''none'';script-src
49
+ ''self'';script-src-attr ''none'';style-src ''self'' https: ''unsafe-inline'';upgrade-insecure-requests'
50
+ Expect-Ct:
51
+ - max-age=0
52
+ Referrer-Policy:
53
+ - no-referrer
54
+ X-Content-Type-Options:
55
+ - nosniff
56
+ X-Dns-Prefetch-Control:
57
+ - 'off'
58
+ X-Download-Options:
59
+ - noopen
60
+ X-Frame-Options:
61
+ - SAMEORIGIN
62
+ X-Permitted-Cross-Domain-Policies:
63
+ - none
64
+ X-Request-Id:
65
+ - 32619697-61a5-4ad1-80ab-9d26a6a74d12
66
+ X-Xss-Protection:
67
+ - '0'
68
+ Set-Cookie:
69
+ - __cf_bm=QdnPZspsJTPGj.ljZ.hfxMSzw0C1in.rjVkGjY75Ht8-1710864397-1.0.1.1-dA2qdL_CwORHen0HwGvbeJXGixoc_htTepIFYUnChePSsMpTdvHI7pWe0ddNWtrRbDD6GEK7TkgM7qPdAXVsaw;
70
+ path=/; expires=Tue, 19-Mar-24 16:36:37 GMT; domain=.workos.com; HttpOnly;
71
+ Secure; SameSite=None
72
+ - __cfruid=a7cc4637e2746cb557755f0665c5f2a6206b907a-1710864397; path=/; domain=.workos.com;
73
+ HttpOnly; Secure; SameSite=None
74
+ Server:
75
+ - cloudflare
76
+ body:
77
+ encoding: UTF-8
78
+ string: '{"error":"invalid_grant","error_description":"Invalid refresh token."}'
79
+ http_version:
80
+ recorded_at: Tue, 19 Mar 2024 16:06:37 GMT
81
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,81 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.workos.com/user_management/authenticate
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"refresh_token":"some_refresh_token","client_id":"client_123","client_secret":"<API_KEY>","ip_address":"200.240.210.16","user_agent":"Mozilla/5.0
9
+ (Macintosh; Intel Mac OS X 10_15_7) Chrome/108.0.0.0 Safari/537.36","grant_type":"refresh_token"}'
10
+ headers:
11
+ Content-Type:
12
+ - application/json
13
+ Accept-Encoding:
14
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
15
+ Accept:
16
+ - "*/*"
17
+ User-Agent:
18
+ - WorkOS; ruby/3.2.2; arm64-darwin22; v4.0.0
19
+ response:
20
+ status:
21
+ code: 200
22
+ message: OK
23
+ headers:
24
+ Date:
25
+ - Mon, 18 Mar 2024 19:00:53 GMT
26
+ Content-Type:
27
+ - application/json; charset=utf-8
28
+ Transfer-Encoding:
29
+ - chunked
30
+ Connection:
31
+ - keep-alive
32
+ Cf-Ray:
33
+ - 866777d63b4627e8-SLC
34
+ Cf-Cache-Status:
35
+ - DYNAMIC
36
+ Etag:
37
+ - W/"335-M3MDQYhs5724SayBHHCwnBDn3qA"
38
+ Strict-Transport-Security:
39
+ - max-age=15552000; includeSubDomains
40
+ Vary:
41
+ - Origin, Accept-Encoding
42
+ Via:
43
+ - 1.1 spaces-router (devel)
44
+ Access-Control-Allow-Credentials:
45
+ - 'true'
46
+ Content-Security-Policy:
47
+ - 'default-src ''self'';base-uri ''self'';block-all-mixed-content;font-src ''self''
48
+ https: data:;frame-ancestors ''self'';img-src ''self'' data:;object-src ''none'';script-src
49
+ ''self'';script-src-attr ''none'';style-src ''self'' https: ''unsafe-inline'';upgrade-insecure-requests'
50
+ Expect-Ct:
51
+ - max-age=0
52
+ Referrer-Policy:
53
+ - no-referrer
54
+ X-Content-Type-Options:
55
+ - nosniff
56
+ X-Dns-Prefetch-Control:
57
+ - 'off'
58
+ X-Download-Options:
59
+ - noopen
60
+ X-Frame-Options:
61
+ - SAMEORIGIN
62
+ X-Permitted-Cross-Domain-Policies:
63
+ - none
64
+ X-Request-Id:
65
+ - 995ed1ed-e892-4049-86c9-0e07baa6cc4b
66
+ X-Xss-Protection:
67
+ - '0'
68
+ Set-Cookie:
69
+ - __cf_bm=2NHqv1cd1BisOc8KKcQ0oNzFxZZT4OHQd6c2QDuGnUU-1710788453-1.0.1.1-4BxBRzVrhL7rCH895PcfORXr_6Rnj3Oh5w1YG4xi7X1st62LMzb5dHZO7u7P.V1P8nBDAAt3Wbz7xsDTWrfWJg;
70
+ path=/; expires=Mon, 18-Mar-24 19:30:53 GMT; domain=.workos.com; HttpOnly;
71
+ Secure; SameSite=None
72
+ - __cfruid=06035c17e9b60a1d7a42a5b568146a0bb71a06dc-1710788453; path=/; domain=.workos.com;
73
+ HttpOnly; Secure; SameSite=None
74
+ Server:
75
+ - cloudflare
76
+ body:
77
+ encoding: UTF-8
78
+ string: '{"access_token":"<ACCESS_TOKEN>","refresh_token":"<REFRESH_TOKEN>"}'
79
+ http_version:
80
+ recorded_at: Mon, 18 Mar 2024 19:00:53 GMT
81
+ recorded_with: VCR 5.0.0
@@ -75,7 +75,7 @@ http_interactions:
75
75
  - cloudflare
76
76
  body:
77
77
  encoding: ASCII-8BIT
78
- string: '{"user":{"object":"user","id":"user_01H93ZY4F80YZRRS6N59Z2HFVS","email":"test@workos.app","email_verified":false,"first_name":"Lucille","last_name":"Bluth","created_at":"2023-08-30T19:50:13.214Z","updated_at":"2023-08-30T19:50:13.214Z","user_type":"managed","sso_profile_id":"prof_01H93ZTVWYPAT4RKDSPFPPXH0J"}}'
78
+ string: '{"user":{"object":"user","id":"user_01H93ZY4F80YZRRS6N59Z2HFVS","email":"test@workos.app","email_verified":false,"first_name":"Lucille","last_name":"Bluth","created_at":"2023-08-30T19:50:13.214Z","updated_at":"2023-08-30T19:50:13.214Z","user_type":"managed","sso_profile_id":"prof_01H93ZTVWYPAT4RKDSPFPPXH0J"},"access_token":"<ACCESS_TOKEN>","refresh_token":"<REFRESH_TOKEN>"}'
79
79
  http_version:
80
80
  recorded_at: Wed, 30 Aug 2023 19:51:51 GMT
81
81
  recorded_with: VCR 5.0.0
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: 4.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - WorkOS
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-08 00:00:00.000000000 Z
11
+ date: 2024-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sorbet-runtime
@@ -182,6 +182,7 @@ files:
182
182
  - lib/workos/events.rb
183
183
  - lib/workos/factor.rb
184
184
  - lib/workos/hash_provider.rb
185
+ - lib/workos/impersonator.rb
185
186
  - lib/workos/invitation.rb
186
187
  - lib/workos/mfa.rb
187
188
  - lib/workos/organization.rb
@@ -191,6 +192,7 @@ files:
191
192
  - lib/workos/portal.rb
192
193
  - lib/workos/profile.rb
193
194
  - lib/workos/profile_and_token.rb
195
+ - lib/workos/refresh_authentication_response.rb
194
196
  - lib/workos/sso.rb
195
197
  - lib/workos/types.rb
196
198
  - lib/workos/types/audit_log_export_struct.rb
@@ -364,6 +366,7 @@ files:
364
366
  - spec/support/fixtures/vcr_cassettes/sso/profile.yml
365
367
  - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_code/invalid.yml
366
368
  - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_code/valid.yml
369
+ - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_code/valid_with_impersonator.yml
367
370
  - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_email_verification/invalid.yml
368
371
  - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_email_verification/valid.yml
369
372
  - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_magic_auth/invalid.yml
@@ -372,6 +375,8 @@ files:
372
375
  - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_organization_selection/valid.yml
373
376
  - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_password/invalid.yml
374
377
  - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_password/valid.yml
378
+ - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_refresh_code/invalid.yml
379
+ - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_refresh_token/valid.yml
375
380
  - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_totp/invalid.yml
376
381
  - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_totp/valid.yml
377
382
  - spec/support/fixtures/vcr_cassettes/user_management/confirm_password_reset/invalid.yml
@@ -549,6 +554,7 @@ test_files:
549
554
  - spec/support/fixtures/vcr_cassettes/sso/profile.yml
550
555
  - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_code/invalid.yml
551
556
  - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_code/valid.yml
557
+ - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_code/valid_with_impersonator.yml
552
558
  - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_email_verification/invalid.yml
553
559
  - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_email_verification/valid.yml
554
560
  - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_magic_auth/invalid.yml
@@ -557,6 +563,8 @@ test_files:
557
563
  - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_organization_selection/valid.yml
558
564
  - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_password/invalid.yml
559
565
  - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_password/valid.yml
566
+ - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_refresh_code/invalid.yml
567
+ - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_refresh_token/valid.yml
560
568
  - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_totp/invalid.yml
561
569
  - spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_totp/valid.yml
562
570
  - spec/support/fixtures/vcr_cassettes/user_management/confirm_password_reset/invalid.yml