workos 5.17.1 → 5.19.0
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 +4 -4
- data/.rubocop.yml +6 -2
- data/Gemfile.lock +1 -1
- data/lib/workos/client.rb +1 -1
- data/lib/workos/mfa.rb +0 -1
- data/lib/workos/session.rb +0 -1
- data/lib/workos/user_management.rb +56 -18
- data/lib/workos/version.rb +1 -1
- data/spec/lib/workos/user_management_spec.rb +11 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/update_user/email.yml +82 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b64aa946db63d75ad0e7b560a904f441d2acfe4f320138c90884c5382a8da26e
|
4
|
+
data.tar.gz: 9038133e40d856eee210c2298739995e3aa8cceae91b1415542955c6bea16226
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c16ee35f4494b5acd119ae6a354d0ba3fa7d9e892310d8388133ff54c0e0930f3d19a20c96d3ebe5b99d7fccd8acf213eb78e6d679967c972c4c4abc15ad3cfd
|
7
|
+
data.tar.gz: 88a97b1723b6dd505b19e8911c6eccef2b2adda01e996959cffa73ec82d71bf85d1011e517f660085d5c388f6474dad2eb7f0b78352e5f5b458671510b936813
|
data/.rubocop.yml
CHANGED
@@ -12,10 +12,14 @@ Layout/LineLength:
|
|
12
12
|
- '(\A|\s)/.*?/'
|
13
13
|
Metrics/BlockLength:
|
14
14
|
AllowedMethods: ['describe', 'context', 'before', 'it']
|
15
|
+
Metrics/ClassLength:
|
16
|
+
Enabled: false
|
17
|
+
Metrics/CyclomaticComplexity:
|
18
|
+
Enabled: false
|
15
19
|
Metrics/MethodLength:
|
16
|
-
|
20
|
+
Enabled: false
|
17
21
|
Metrics/ModuleLength:
|
18
|
-
|
22
|
+
Enabled: false
|
19
23
|
Metrics/ParameterLists:
|
20
24
|
Max: 6
|
21
25
|
Naming/ConstantName:
|
data/Gemfile.lock
CHANGED
data/lib/workos/client.rb
CHANGED
@@ -86,7 +86,7 @@ module WorkOS
|
|
86
86
|
].join('; ')
|
87
87
|
end
|
88
88
|
|
89
|
-
# rubocop:disable Metrics/
|
89
|
+
# rubocop:disable Metrics/AbcSize:
|
90
90
|
def handle_error_response(response:)
|
91
91
|
http_status = response.code.to_i
|
92
92
|
json = JSON.parse(response.body)
|
data/lib/workos/mfa.rb
CHANGED
data/lib/workos/session.rb
CHANGED
@@ -64,7 +64,6 @@ module WorkOS
|
|
64
64
|
# @return [Hash] A hash containing a new sealed session, the authentication response,
|
65
65
|
# and a reason if the refresh failed
|
66
66
|
# rubocop:disable Metrics/AbcSize
|
67
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
68
67
|
# rubocop:disable Metrics/PerceivedComplexity
|
69
68
|
def refresh(options = nil)
|
70
69
|
cookie_password = options.nil? || options[:cookie_password].nil? ? @cookie_password : options[:cookie_password]
|
@@ -6,8 +6,6 @@ require 'uri'
|
|
6
6
|
module WorkOS
|
7
7
|
# The UserManagement module provides convenience methods for working with the
|
8
8
|
# WorkOS User platform. You'll need a valid API key.
|
9
|
-
|
10
|
-
# rubocop:disable Metrics/ModuleLength
|
11
9
|
module UserManagement
|
12
10
|
module Types
|
13
11
|
# The ProviderEnum is a declaration of a
|
@@ -217,6 +215,7 @@ module WorkOS
|
|
217
215
|
# Update a user
|
218
216
|
#
|
219
217
|
# @param [String] id of the user.
|
218
|
+
# @param [String] email of the user.
|
220
219
|
# @param [String] first_name The user's first name.
|
221
220
|
# @param [String] last_name The user's last name.
|
222
221
|
# @param [Boolean] email_verified Whether the user's email address was previously verified.
|
@@ -228,6 +227,7 @@ module WorkOS
|
|
228
227
|
# @return [WorkOS::User]
|
229
228
|
def update_user(
|
230
229
|
id:,
|
230
|
+
email: nil,
|
231
231
|
first_name: nil,
|
232
232
|
last_name: nil,
|
233
233
|
email_verified: nil,
|
@@ -238,6 +238,7 @@ module WorkOS
|
|
238
238
|
request = put_request(
|
239
239
|
path: "/user_management/users/#{id}",
|
240
240
|
body: {
|
241
|
+
email: email,
|
241
242
|
first_name: first_name,
|
242
243
|
last_name: last_name,
|
243
244
|
email_verified: email_verified,
|
@@ -277,9 +278,20 @@ module WorkOS
|
|
277
278
|
# @param [String] client_id The WorkOS client ID for the environment
|
278
279
|
# @param [String] ip_address The IP address of the request from the user who is attempting to authenticate.
|
279
280
|
# @param [String] user_agent The user agent of the request from the user who is attempting to authenticate.
|
281
|
+
# @param [Hash] session An optional hash that determines whether the session should be sealed and
|
282
|
+
# the optional cookie password.
|
280
283
|
#
|
281
284
|
# @return WorkOS::AuthenticationResponse
|
282
|
-
def authenticate_with_password(
|
285
|
+
def authenticate_with_password(
|
286
|
+
email:,
|
287
|
+
password:,
|
288
|
+
client_id:,
|
289
|
+
ip_address: nil,
|
290
|
+
user_agent: nil,
|
291
|
+
session: nil
|
292
|
+
)
|
293
|
+
validate_session(session)
|
294
|
+
|
283
295
|
response = execute_request(
|
284
296
|
request: post_request(
|
285
297
|
path: '/user_management/authenticate',
|
@@ -295,7 +307,7 @@ module WorkOS
|
|
295
307
|
),
|
296
308
|
)
|
297
309
|
|
298
|
-
WorkOS::AuthenticationResponse.new(response.body)
|
310
|
+
WorkOS::AuthenticationResponse.new(response.body, session)
|
299
311
|
end
|
300
312
|
|
301
313
|
# Authenticate a user using OAuth or an organization's SSO connection.
|
@@ -316,9 +328,7 @@ module WorkOS
|
|
316
328
|
user_agent: nil,
|
317
329
|
session: nil
|
318
330
|
)
|
319
|
-
|
320
|
-
raise ArgumentError, 'cookie_password is required when sealing session'
|
321
|
-
end
|
331
|
+
validate_session(session)
|
322
332
|
|
323
333
|
response = execute_request(
|
324
334
|
request: post_request(
|
@@ -356,9 +366,7 @@ module WorkOS
|
|
356
366
|
user_agent: nil,
|
357
367
|
session: nil
|
358
368
|
)
|
359
|
-
|
360
|
-
raise ArgumentError, 'cookie_password is required when sealing session'
|
361
|
-
end
|
369
|
+
validate_session(session)
|
362
370
|
|
363
371
|
response = execute_request(
|
364
372
|
request: post_request(
|
@@ -387,16 +395,22 @@ module WorkOS
|
|
387
395
|
# @param [String] link_authorization_code Used to link an OAuth profile to an existing user,
|
388
396
|
# after having completed a Magic Code challenge.
|
389
397
|
# @param [String] user_agent The user agent of the request from the user who is attempting to authenticate.
|
398
|
+
# @param [Hash] session An optional hash that determines whether the session should be sealed and
|
399
|
+
# the optional cookie password.
|
390
400
|
#
|
391
401
|
# @return WorkOS::AuthenticationResponse
|
402
|
+
# rubocop:disable Metrics/ParameterLists
|
392
403
|
def authenticate_with_magic_auth(
|
393
404
|
code:,
|
394
405
|
email:,
|
395
406
|
client_id:,
|
396
407
|
ip_address: nil,
|
397
408
|
user_agent: nil,
|
398
|
-
link_authorization_code: nil
|
409
|
+
link_authorization_code: nil,
|
410
|
+
session: nil
|
399
411
|
)
|
412
|
+
validate_session(session)
|
413
|
+
|
400
414
|
response = execute_request(
|
401
415
|
request: post_request(
|
402
416
|
path: '/user_management/authenticate',
|
@@ -413,8 +427,9 @@ module WorkOS
|
|
413
427
|
),
|
414
428
|
)
|
415
429
|
|
416
|
-
WorkOS::AuthenticationResponse.new(response.body)
|
430
|
+
WorkOS::AuthenticationResponse.new(response.body, session)
|
417
431
|
end
|
432
|
+
# rubocop:enable Metrics/ParameterLists
|
418
433
|
|
419
434
|
# Authenticate a user into an organization they are a member of.
|
420
435
|
#
|
@@ -423,6 +438,8 @@ module WorkOS
|
|
423
438
|
# @param [String] pending_authentication_token The pending authentication token
|
424
439
|
# @param [String] ip_address The IP address of the request from the user who is attempting to authenticate.
|
425
440
|
# @param [String] user_agent The user agent of the request from the user who is attempting to authenticate.
|
441
|
+
# @param [Hash] session An optional hash that determines whether the session should be sealed and
|
442
|
+
# the optional cookie password.
|
426
443
|
#
|
427
444
|
# @return WorkOS::AuthenticationResponse
|
428
445
|
def authenticate_with_organization_selection(
|
@@ -430,8 +447,11 @@ module WorkOS
|
|
430
447
|
organization_id:,
|
431
448
|
pending_authentication_token:,
|
432
449
|
ip_address: nil,
|
433
|
-
user_agent: nil
|
450
|
+
user_agent: nil,
|
451
|
+
session: nil
|
434
452
|
)
|
453
|
+
validate_session(session)
|
454
|
+
|
435
455
|
response = execute_request(
|
436
456
|
request: post_request(
|
437
457
|
path: '/user_management/authenticate',
|
@@ -447,7 +467,7 @@ module WorkOS
|
|
447
467
|
),
|
448
468
|
)
|
449
469
|
|
450
|
-
WorkOS::AuthenticationResponse.new(response.body)
|
470
|
+
WorkOS::AuthenticationResponse.new(response.body, session)
|
451
471
|
end
|
452
472
|
|
453
473
|
# Authenticate a user using TOTP.
|
@@ -460,16 +480,22 @@ module WorkOS
|
|
460
480
|
# authentication request.
|
461
481
|
# @param [String] ip_address The IP address of the request from the user who is attempting to authenticate.
|
462
482
|
# @param [String] user_agent The user agent of the request from the user who is attempting to authenticate.
|
483
|
+
# @param [Hash] session An optional hash that determines whether the session should be sealed and
|
484
|
+
# the optional cookie password.
|
463
485
|
#
|
464
486
|
# @return WorkOS::AuthenticationResponse
|
487
|
+
# rubocop:disable Metrics/ParameterLists
|
465
488
|
def authenticate_with_totp(
|
466
489
|
code:,
|
467
490
|
client_id:,
|
468
491
|
pending_authentication_token:,
|
469
492
|
authentication_challenge_id:,
|
470
493
|
ip_address: nil,
|
471
|
-
user_agent: nil
|
494
|
+
user_agent: nil,
|
495
|
+
session: nil
|
472
496
|
)
|
497
|
+
validate_session(session)
|
498
|
+
|
473
499
|
response = execute_request(
|
474
500
|
request: post_request(
|
475
501
|
path: '/user_management/authenticate',
|
@@ -486,8 +512,9 @@ module WorkOS
|
|
486
512
|
),
|
487
513
|
)
|
488
514
|
|
489
|
-
WorkOS::AuthenticationResponse.new(response.body)
|
515
|
+
WorkOS::AuthenticationResponse.new(response.body, session)
|
490
516
|
end
|
517
|
+
# rubocop:enable Metrics/ParameterLists
|
491
518
|
|
492
519
|
# Authenticate a user using Email Verification Code.
|
493
520
|
#
|
@@ -497,6 +524,8 @@ module WorkOS
|
|
497
524
|
# authentication attempt due to an unverified email address.
|
498
525
|
# @param [String] ip_address The IP address of the request from the user who is attempting to authenticate.
|
499
526
|
# @param [String] user_agent The user agent of the request from the user who is attempting to authenticate.
|
527
|
+
# @param [Hash] session An optional hash that determines whether the session should be sealed and
|
528
|
+
# the optional cookie password.
|
500
529
|
#
|
501
530
|
# @return WorkOS::AuthenticationResponse
|
502
531
|
def authenticate_with_email_verification(
|
@@ -504,8 +533,11 @@ module WorkOS
|
|
504
533
|
client_id:,
|
505
534
|
pending_authentication_token:,
|
506
535
|
ip_address: nil,
|
507
|
-
user_agent: nil
|
536
|
+
user_agent: nil,
|
537
|
+
session: nil
|
508
538
|
)
|
539
|
+
validate_session(session)
|
540
|
+
|
509
541
|
response = execute_request(
|
510
542
|
request: post_request(
|
511
543
|
path: '/user_management/authenticate',
|
@@ -521,7 +553,7 @@ module WorkOS
|
|
521
553
|
),
|
522
554
|
)
|
523
555
|
|
524
|
-
WorkOS::AuthenticationResponse.new(response.body)
|
556
|
+
WorkOS::AuthenticationResponse.new(response.body, session)
|
525
557
|
end
|
526
558
|
|
527
559
|
# Get the logout URL for a session
|
@@ -1081,6 +1113,12 @@ module WorkOS
|
|
1081
1113
|
|
1082
1114
|
private
|
1083
1115
|
|
1116
|
+
def validate_session(session)
|
1117
|
+
return unless session && (session[:seal_session] == true) && session[:cookie_password].nil?
|
1118
|
+
|
1119
|
+
raise ArgumentError, 'cookie_password is required when sealing session'
|
1120
|
+
end
|
1121
|
+
|
1084
1122
|
def validate_authorization_url_arguments(
|
1085
1123
|
provider:,
|
1086
1124
|
connection_id:,
|
data/lib/workos/version.rb
CHANGED
@@ -343,6 +343,17 @@ describe WorkOS::UserManagement do
|
|
343
343
|
end
|
344
344
|
end
|
345
345
|
|
346
|
+
it 'can update email addresses' do
|
347
|
+
VCR.use_cassette 'user_management/update_user/email' do
|
348
|
+
user = described_class.update_user(
|
349
|
+
id: 'user_01H7TVSKS45SDHN5V9XPSM6H44',
|
350
|
+
email: 'jane@example.com',
|
351
|
+
)
|
352
|
+
expect(user.email).to eq('jane@example.com')
|
353
|
+
expect(user.email_verified).to eq(false)
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
346
357
|
context 'with an invalid payload' do
|
347
358
|
it 'returns an error' do
|
348
359
|
VCR.use_cassette 'user_management/update_user/invalid' do
|
@@ -0,0 +1,82 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: put
|
5
|
+
uri: https://api.workos.com/user_management/users/user_01H7TVSKS45SDHN5V9XPSM6H44
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"email":"jane@example.com"}'
|
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.0.2; arm64-darwin21; v2.16.0
|
18
|
+
Authorization:
|
19
|
+
- Bearer <API_KEY>
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Date:
|
26
|
+
- Fri, 25 Aug 2023 23:37:04 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Transfer-Encoding:
|
30
|
+
- chunked
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Cf-Ray:
|
34
|
+
- 7fc7a9287d0330ba-SEA
|
35
|
+
Cf-Cache-Status:
|
36
|
+
- DYNAMIC
|
37
|
+
Etag:
|
38
|
+
- W/"153-w5d8Z7u7b9Obt9NziECtNSAY9Ac"
|
39
|
+
Strict-Transport-Security:
|
40
|
+
- max-age=15552000; includeSubDomains
|
41
|
+
Vary:
|
42
|
+
- Origin, Accept-Encoding
|
43
|
+
Via:
|
44
|
+
- 1.1 spaces-router (devel)
|
45
|
+
Access-Control-Allow-Credentials:
|
46
|
+
- 'true'
|
47
|
+
Content-Security-Policy:
|
48
|
+
- 'default-src ''self'';base-uri ''self'';block-all-mixed-content;font-src ''self''
|
49
|
+
https: data:;frame-ancestors ''self'';img-src ''self'' data:;object-src ''none'';script-src
|
50
|
+
''self'';script-src-attr ''none'';style-src ''self'' https: ''unsafe-inline'';upgrade-insecure-requests'
|
51
|
+
Expect-Ct:
|
52
|
+
- max-age=0
|
53
|
+
Referrer-Policy:
|
54
|
+
- no-referrer
|
55
|
+
X-Content-Type-Options:
|
56
|
+
- nosniff
|
57
|
+
X-Dns-Prefetch-Control:
|
58
|
+
- 'off'
|
59
|
+
X-Download-Options:
|
60
|
+
- noopen
|
61
|
+
X-Frame-Options:
|
62
|
+
- SAMEORIGIN
|
63
|
+
X-Permitted-Cross-Domain-Policies:
|
64
|
+
- none
|
65
|
+
X-Request-Id:
|
66
|
+
- b333b9e1-c9ec-4e99-ae4f-17a854859cf1
|
67
|
+
X-Xss-Protection:
|
68
|
+
- '0'
|
69
|
+
Set-Cookie:
|
70
|
+
- __cf_bm=adC6w3NUNGTpdZDzNn39guANJ9wi798uCuqc_EI8190-1693006624-0-AcpsuyzFE/KdM7ev5pSVTt2vnGqCSZBOuQYZ0iKFiJT0mBlAuNITn3hICEKvcZ4LH7JUIyjnEOWfq2w7JyRmrJ4=;
|
71
|
+
path=/; expires=Sat, 26-Aug-23 00:07:04 GMT; domain=.workos.com; HttpOnly;
|
72
|
+
Secure; SameSite=None
|
73
|
+
- __cfruid=1d0cc3edf886cc7b90bd0c9c3226f5611a385c1a-1693006624; path=/; domain=.workos.com;
|
74
|
+
HttpOnly; Secure; SameSite=None
|
75
|
+
Server:
|
76
|
+
- cloudflare
|
77
|
+
body:
|
78
|
+
encoding: ASCII-8BIT
|
79
|
+
string: '{"object":"user","id":"user_01H7TVSKS45SDHN5V9XPSM6H44","email":"jane@example.com","email_verified":false,"first_name":"Jane","last_name":"Doe","created_at":"2023-08-14T20:28:58.929Z","updated_at":"2023-08-25T22:57:44.262Z","user_type":"unmanaged","email_verified_at":null,"google_oauth_profile_id":null,"microsoft_oauth_profile_id":null}'
|
80
|
+
http_version:
|
81
|
+
recorded_at: Fri, 12 May 2025 23:37:04 GMT
|
82
|
+
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: 5.
|
4
|
+
version: 5.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- WorkOS
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: encryptor
|
@@ -368,6 +368,7 @@ files:
|
|
368
368
|
- spec/support/fixtures/vcr_cassettes/user_management/send_verification_email/valid.yml
|
369
369
|
- spec/support/fixtures/vcr_cassettes/user_management/update_organization_membership/invalid.yml
|
370
370
|
- spec/support/fixtures/vcr_cassettes/user_management/update_organization_membership/valid.yml
|
371
|
+
- spec/support/fixtures/vcr_cassettes/user_management/update_user/email.yml
|
371
372
|
- spec/support/fixtures/vcr_cassettes/user_management/update_user/invalid.yml
|
372
373
|
- spec/support/fixtures/vcr_cassettes/user_management/update_user/valid.yml
|
373
374
|
- spec/support/fixtures/vcr_cassettes/user_management/update_user_password/invalid.yml
|
@@ -590,6 +591,7 @@ test_files:
|
|
590
591
|
- spec/support/fixtures/vcr_cassettes/user_management/send_verification_email/valid.yml
|
591
592
|
- spec/support/fixtures/vcr_cassettes/user_management/update_organization_membership/invalid.yml
|
592
593
|
- spec/support/fixtures/vcr_cassettes/user_management/update_organization_membership/valid.yml
|
594
|
+
- spec/support/fixtures/vcr_cassettes/user_management/update_user/email.yml
|
593
595
|
- spec/support/fixtures/vcr_cassettes/user_management/update_user/invalid.yml
|
594
596
|
- spec/support/fixtures/vcr_cassettes/user_management/update_user/valid.yml
|
595
597
|
- spec/support/fixtures/vcr_cassettes/user_management/update_user_password/invalid.yml
|