workos 5.25.0 → 5.26.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86d12c42e6f45139b343d1f519807176eca7a9ac77dbd2d3de0287a9406c50c4
4
- data.tar.gz: 3addd0959c8b7b8c2caae994b694bfda1eabe41499f540d76e71865e9ae9b35f
3
+ metadata.gz: 70fb176f7fd3b899bb8c88f2123536778e2a026d97582de2e1beb9525b2bec5b
4
+ data.tar.gz: 164650f3cdbe0181b9d249c69fc6bab6713f41bef3e419dbb8ce765211123068
5
5
  SHA512:
6
- metadata.gz: e286d3aa2d010bbab396d9267795c9eee35cac00f7d3c4c95fb35d70b08df133d32b0081a5f83a1ecf1fe28d663f660947b27756b7225a22ed7b345d4e5d5898
7
- data.tar.gz: 9571637a3bda0ce330a54ea0a8a09076905fdece0b2e85565a3dd9510d5c3f27d52021cca7a51372d7bc0c3de00a7aeaacb521e0522b9a849df8081d5c316828
6
+ metadata.gz: cd3a1e2254870e8d34ace357916f6a8287fefdfb0c89e9e82ed679e02460caad0f457a2a60c56fa19afefc9d74a92427603efc12c4a181c13fe27bf4b4babc27
7
+ data.tar.gz: 89e8b4854838de9fc893c16380df4d0b75ef0fb68659b25cbca140310c4cc7dd00e371183c432d60d978548059a941a8410a2e143cefed6011b95be219f84d43
data/.gitignore CHANGED
@@ -49,3 +49,4 @@
49
49
  # .rubocop-https?--*
50
50
 
51
51
  .vscode
52
+ .idea/
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- workos (5.25.0)
4
+ workos (5.26.0)
5
5
  encryptor (~> 3.0)
6
6
  jwt (~> 2.8)
7
7
 
@@ -7,7 +7,7 @@ module WorkOS
7
7
  class OrganizationMembership
8
8
  include HashProvider
9
9
 
10
- attr_accessor :id, :user_id, :organization_id, :status, :role, :created_at, :updated_at
10
+ attr_accessor :id, :user_id, :organization_id, :status, :role, :roles, :created_at, :updated_at
11
11
 
12
12
  def initialize(json)
13
13
  hash = JSON.parse(json, symbolize_names: true)
@@ -17,6 +17,7 @@ module WorkOS
17
17
  @organization_id = hash[:organization_id]
18
18
  @status = hash[:status]
19
19
  @role = hash[:role]
20
+ @roles = hash[:roles]
20
21
  @created_at = hash[:created_at]
21
22
  @updated_at = hash[:updated_at]
22
23
  end
@@ -28,6 +29,7 @@ module WorkOS
28
29
  organization_id: organization_id,
29
30
  status: status,
30
31
  role: role,
32
+ roles: roles,
31
33
  created_at: created_at,
32
34
  updated_at: updated_at,
33
35
  }
@@ -30,6 +30,7 @@ module WorkOS
30
30
 
31
31
  # Authenticates the user based on the session data
32
32
  # @return [Hash] A hash containing the authentication response and a reason if the authentication failed
33
+ # rubocop:disable Metrics/AbcSize
33
34
  def authenticate
34
35
  return { authenticated: false, reason: 'NO_SESSION_COOKIE_PROVIDED' } if @session_data.nil?
35
36
 
@@ -49,6 +50,7 @@ module WorkOS
49
50
  session_id: decoded['sid'],
50
51
  organization_id: decoded['org_id'],
51
52
  role: decoded['role'],
53
+ roles: decoded['roles'],
52
54
  permissions: decoded['permissions'],
53
55
  entitlements: decoded['entitlements'],
54
56
  feature_flags: decoded['feature_flags'],
@@ -64,7 +66,6 @@ module WorkOS
64
66
  # @option options [String] :organization_id The organization ID to use for refreshing the session
65
67
  # @return [Hash] A hash containing a new sealed session, the authentication response,
66
68
  # and a reason if the refresh failed
67
- # rubocop:disable Metrics/AbcSize
68
69
  # rubocop:disable Metrics/PerceivedComplexity
69
70
  def refresh(options = nil)
70
71
  cookie_password = options.nil? || options[:cookie_password].nil? ? @cookie_password : options[:cookie_password]
@@ -6,8 +6,10 @@ module WorkOS
6
6
  # scopes while generating a widget token.
7
7
  module WidgetScope
8
8
  USERS_TABLE_MANAGE = 'widgets:users-table:manage'
9
+ SSO_MANAGE = 'widgets:sso:manage'
10
+ DOMAIN_VERIFICATION_MANAGE = 'widgets:domain-verification:manage'
9
11
 
10
- ALL = [USERS_TABLE_MANAGE].freeze
12
+ ALL = [USERS_TABLE_MANAGE, SSO_MANAGE, DOMAIN_VERIFICATION_MANAGE].freeze
11
13
  end
12
14
  end
13
15
  end
@@ -926,16 +926,23 @@ module WorkOS
926
926
  # @param [String] user_id The ID of the User.
927
927
  # @param [String] organization_id The ID of the Organization to which the user belongs to.
928
928
  # @param [String] role_slug The slug of the role to grant to this membership. (Optional)
929
+ # @param [Array<String>] role_slugs Array of role slugs to assign to this membership. (Optional)
929
930
  #
930
931
  # @return [WorkOS::OrganizationMembership]
931
- def create_organization_membership(user_id:, organization_id:, role_slug: nil)
932
+ def create_organization_membership(user_id:, organization_id:, role_slug: nil, role_slugs: nil)
933
+ raise ArgumentError, 'Cannot specify both role_slug and role_slugs' if role_slug && role_slugs
934
+
935
+ body = {
936
+ user_id: user_id,
937
+ organization_id: organization_id,
938
+ }
939
+
940
+ body[:role_slugs] = role_slugs if role_slugs
941
+ body[:role_slug] = role_slug if role_slug
942
+
932
943
  request = post_request(
933
944
  path: '/user_management/organization_memberships',
934
- body: {
935
- user_id: user_id,
936
- organization_id: organization_id,
937
- role_slug: role_slug,
938
- }.compact,
945
+ body: body.compact,
939
946
  auth: true,
940
947
  )
941
948
 
@@ -946,17 +953,22 @@ module WorkOS
946
953
 
947
954
  # Update an Organization Membership
948
955
  #
949
- # @param [String] organization_membership_id The ID of the Organization Membership.
950
- # @param [String] role_slug The slug of the role to grant to this membership.
956
+ # @param [String] id The ID of the Organization Membership.
957
+ # @param [String] role_slug The slug of the role to grant to this membership. (Optional)
958
+ # @param [Array<String>] role_slugs Array of role slugs to assign to this membership. (Optional)
951
959
  #
952
960
  # @return [WorkOS::OrganizationMembership]
953
- def update_organization_membership(id:, role_slug:)
961
+ def update_organization_membership(id:, role_slug: nil, role_slugs: nil)
962
+ raise ArgumentError, 'Cannot specify both role_slug and role_slugs' if role_slug && role_slugs
963
+
964
+ body = { id: id }
965
+
966
+ body[:role_slugs] = role_slugs if role_slugs
967
+ body[:role_slug] = role_slug if role_slug
968
+
954
969
  request = put_request(
955
970
  path: "/user_management/organization_memberships/#{id}",
956
- body: {
957
- id: id,
958
- role_slug: role_slug,
959
- },
971
+ body: body.compact,
960
972
  auth: true,
961
973
  )
962
974
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WorkOS
4
- VERSION = '5.25.0'
4
+ VERSION = '5.26.0'
5
5
  end
@@ -108,6 +108,7 @@ describe WorkOS::Session do
108
108
  sid: 'session_id',
109
109
  org_id: 'org_id',
110
110
  role: 'role',
111
+ roles: ['role'],
111
112
  permissions: ['read'],
112
113
  exp: Time.now.to_i + 3600,
113
114
  }
@@ -173,6 +174,7 @@ describe WorkOS::Session do
173
174
  session_id: 'session_id',
174
175
  organization_id: 'org_id',
175
176
  role: 'role',
177
+ roles: ['role'],
176
178
  permissions: ['read'],
177
179
  feature_flags: nil,
178
180
  entitlements: nil,
@@ -188,6 +190,7 @@ describe WorkOS::Session do
188
190
  sid: 'session_id',
189
191
  org_id: 'org_id',
190
192
  role: 'role',
193
+ roles: ['role'],
191
194
  permissions: ['read'],
192
195
  entitlements: ['billing'],
193
196
  exp: Time.now.to_i + 3600,
@@ -208,6 +211,7 @@ describe WorkOS::Session do
208
211
  session_id: 'session_id',
209
212
  organization_id: 'org_id',
210
213
  role: 'role',
214
+ roles: ['role'],
211
215
  permissions: ['read'],
212
216
  entitlements: ['billing'],
213
217
  feature_flags: nil,
@@ -224,6 +228,7 @@ describe WorkOS::Session do
224
228
  sid: 'session_id',
225
229
  org_id: 'org_id',
226
230
  role: 'role',
231
+ roles: ['role'],
227
232
  permissions: ['read'],
228
233
  feature_flags: ['new_feature_enabled'],
229
234
  exp: Time.now.to_i + 3600,
@@ -244,6 +249,7 @@ describe WorkOS::Session do
244
249
  session_id: 'session_id',
245
250
  organization_id: 'org_id',
246
251
  role: 'role',
252
+ roles: ['role'],
247
253
  permissions: ['read'],
248
254
  entitlements: nil,
249
255
  feature_flags: ['new_feature_enabled'],
@@ -1302,6 +1302,23 @@ describe WorkOS::UserManagement do
1302
1302
  end
1303
1303
  end
1304
1304
  end
1305
+
1306
+ context 'with role slugs' do
1307
+ it 'creates an organization membership with multiple roles' do
1308
+ VCR.use_cassette 'user_management/create_organization_membership/valid_multiple_roles' do
1309
+ organization_membership = described_class.create_organization_membership(
1310
+ user_id: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
1311
+ organization_id: 'org_01H5JQDV7R7ATEYZDEG0W5PRYS',
1312
+ role_slugs: %w[admin member],
1313
+ )
1314
+
1315
+ expect(organization_membership.organization_id).to eq('organization_01H5JQDV7R7ATEYZDEG0W5PRYS')
1316
+ expect(organization_membership.user_id).to eq('user_01H5JQDV7R7ATEYZDEG0W5PRYS')
1317
+ expect(organization_membership.roles).to be_an(Array)
1318
+ expect(organization_membership.roles.length).to eq(2)
1319
+ end
1320
+ end
1321
+ end
1305
1322
  end
1306
1323
 
1307
1324
  describe '.update_organization_membership' do
@@ -1329,6 +1346,22 @@ describe WorkOS::UserManagement do
1329
1346
  end
1330
1347
  end
1331
1348
  end
1349
+
1350
+ context 'with role slugs' do
1351
+ it 'updates an organization membership with multiple roles' do
1352
+ VCR.use_cassette('user_management/update_organization_membership/valid_multiple_roles') do
1353
+ organization_membership = WorkOS::UserManagement.update_organization_membership(
1354
+ id: 'om_01H5JQDV7R7ATEYZDEG0W5PRYS',
1355
+ role_slugs: %w[admin editor],
1356
+ )
1357
+
1358
+ expect(organization_membership.organization_id).to eq('organization_01H5JQDV7R7ATEYZDEG0W5PRYS')
1359
+ expect(organization_membership.user_id).to eq('user_01H5JQDV7R7ATEYZDEG0W5PRYS')
1360
+ expect(organization_membership.roles).to be_an(Array)
1361
+ expect(organization_membership.roles.length).to eq(2)
1362
+ end
1363
+ end
1364
+ end
1332
1365
  end
1333
1366
 
1334
1367
  describe '.delete_organization_membership' do
@@ -0,0 +1,76 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.workos.com/user_management/organization_memberships
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"user_id":"user_01H5JQDV7R7ATEYZDEG0W5PRYS","organization_id":"org_01H5JQDV7R7ATEYZDEG0W5PRYS","role_slugs":["admin","member"]}'
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.4; arm64-darwin24; v5.25.0
18
+ Authorization:
19
+ - Bearer <API_KEY>
20
+ response:
21
+ status:
22
+ code: 201
23
+ message: Created
24
+ headers:
25
+ Date:
26
+ - Mon, 06 Oct 2025 19:57:34 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Content-Length:
30
+ - '26'
31
+ Connection:
32
+ - keep-alive
33
+ Server:
34
+ - cloudflare
35
+ Cf-Ray:
36
+ - 98a7ba7fea91ead7-ORD
37
+ Cf-Cache-Status:
38
+ - DYNAMIC
39
+ Etag:
40
+ - W/"1a-pljHtlo127JYJR4E/RYOPb6ucbw"
41
+ Strict-Transport-Security:
42
+ - max-age=15552000; includeSubDomains
43
+ Vary:
44
+ - Origin, Accept-Encoding
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
+ - 6507807d-d3b9-4e8f-9ca8-f84c6f9c6eb4
67
+ X-Xss-Protection:
68
+ - '0'
69
+ Set-Cookie:
70
+ - _cfuvid=recfIuOTSO3jIxK5SUOdhHRRfTGoiOFOMgSbEpVIjpg-1759780654123-0.0.1.1-604800000;
71
+ path=/; domain=.workos.com; HttpOnly; Secure; SameSite=None
72
+ body:
73
+ encoding: UTF-8
74
+ string: '{"object":"organization_membership","id":"om_01H5JQDV7R7ATEYZDEG0W5PRYS","user_id":"user_01H5JQDV7R7ATEYZDEG0W5PRYS","organization_id":"organization_01H5JQDV7R7ATEYZDEG0W5PRYS","status":"active","role":{"slug":"member"}, "roles":[{"slug":"member"}, {"slug":"admin"}], "created_at":"2023-07-18T02:07:19.911Z","updated_at":"2023-07-18T02:07:19.911Z"}'
75
+ recorded_at: Mon, 06 Oct 2025 19:57:34 GMT
76
+ recorded_with: VCR 6.3.1
@@ -0,0 +1,76 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: put
5
+ uri: https://api.workos.com/user_management/organization_memberships/om_01H5JQDV7R7ATEYZDEG0W5PRYS
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"id":"om_01H5JQDV7R7ATEYZDEG0W5PRYS","role_slugs":["admin","editor"]}'
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.4; arm64-darwin24; v5.25.0
18
+ Authorization:
19
+ - Bearer <API_KEY>
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Date:
26
+ - Tue, 07 Oct 2025 14:22:26 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Content-Length:
30
+ - '26'
31
+ Connection:
32
+ - keep-alive
33
+ Server:
34
+ - cloudflare
35
+ Cf-Ray:
36
+ - 98ae0cf66dd9344d-ORD
37
+ Cf-Cache-Status:
38
+ - DYNAMIC
39
+ Etag:
40
+ - W/"1a-pljHtlo127JYJR4E/RYOPb6ucbw"
41
+ Strict-Transport-Security:
42
+ - max-age=15552000; includeSubDomains
43
+ Vary:
44
+ - Origin, Accept-Encoding
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
+ - 92b6245b-40a8-4bdd-95d1-e32f6e9d1d70
67
+ X-Xss-Protection:
68
+ - '0'
69
+ Set-Cookie:
70
+ - _cfuvid=hq7zKar8D7SHPwNzTjLw.29beujgLQlq6cOYaWvYhEM-1759846946364-0.0.1.1-604800000;
71
+ path=/; domain=.workos.com; HttpOnly; Secure; SameSite=None
72
+ body:
73
+ encoding: UTF-8
74
+ string: '{"object":"organization_membership","id":"om_01H5JQDV7R7ATEYZDEG0W5PRYS","user_id":"user_01H5JQDV7R7ATEYZDEG0W5PRYS","organization_id":"organization_01H5JQDV7R7ATEYZDEG0W5PRYS","status":"active","role":{"slug":"admin"},"roles":[{"slug":"admin"},{"slug":"editor"}],"created_at":"2023-07-18T02:07:19.911Z","updated_at":"2023-07-18T02:07:19.911Z"}'
75
+ recorded_at: Tue, 07 Oct 2025 14:22:26 GMT
76
+ recorded_with: VCR 6.3.1
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.25.0
4
+ version: 5.26.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-08-05 00:00:00.000000000 Z
11
+ date: 2025-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: encryptor
@@ -326,6 +326,7 @@ files:
326
326
  - spec/support/fixtures/vcr_cassettes/user_management/create_magic_auth/valid.yml
327
327
  - spec/support/fixtures/vcr_cassettes/user_management/create_organization_membership/invalid.yml
328
328
  - spec/support/fixtures/vcr_cassettes/user_management/create_organization_membership/valid.yml
329
+ - spec/support/fixtures/vcr_cassettes/user_management/create_organization_membership/valid_multiple_roles.yml
329
330
  - spec/support/fixtures/vcr_cassettes/user_management/create_password_reset/valid.yml
330
331
  - spec/support/fixtures/vcr_cassettes/user_management/create_user_invalid.yml
331
332
  - spec/support/fixtures/vcr_cassettes/user_management/create_user_valid.yml
@@ -377,6 +378,7 @@ files:
377
378
  - spec/support/fixtures/vcr_cassettes/user_management/send_verification_email/valid.yml
378
379
  - spec/support/fixtures/vcr_cassettes/user_management/update_organization_membership/invalid.yml
379
380
  - spec/support/fixtures/vcr_cassettes/user_management/update_organization_membership/valid.yml
381
+ - spec/support/fixtures/vcr_cassettes/user_management/update_organization_membership/valid_multiple_roles.yml
380
382
  - spec/support/fixtures/vcr_cassettes/user_management/update_user/email.yml
381
383
  - spec/support/fixtures/vcr_cassettes/user_management/update_user/invalid.yml
382
384
  - spec/support/fixtures/vcr_cassettes/user_management/update_user/valid.yml
@@ -557,6 +559,7 @@ test_files:
557
559
  - spec/support/fixtures/vcr_cassettes/user_management/create_magic_auth/valid.yml
558
560
  - spec/support/fixtures/vcr_cassettes/user_management/create_organization_membership/invalid.yml
559
561
  - spec/support/fixtures/vcr_cassettes/user_management/create_organization_membership/valid.yml
562
+ - spec/support/fixtures/vcr_cassettes/user_management/create_organization_membership/valid_multiple_roles.yml
560
563
  - spec/support/fixtures/vcr_cassettes/user_management/create_password_reset/valid.yml
561
564
  - spec/support/fixtures/vcr_cassettes/user_management/create_user_invalid.yml
562
565
  - spec/support/fixtures/vcr_cassettes/user_management/create_user_valid.yml
@@ -608,6 +611,7 @@ test_files:
608
611
  - spec/support/fixtures/vcr_cassettes/user_management/send_verification_email/valid.yml
609
612
  - spec/support/fixtures/vcr_cassettes/user_management/update_organization_membership/invalid.yml
610
613
  - spec/support/fixtures/vcr_cassettes/user_management/update_organization_membership/valid.yml
614
+ - spec/support/fixtures/vcr_cassettes/user_management/update_organization_membership/valid_multiple_roles.yml
611
615
  - spec/support/fixtures/vcr_cassettes/user_management/update_user/email.yml
612
616
  - spec/support/fixtures/vcr_cassettes/user_management/update_user/invalid.yml
613
617
  - spec/support/fixtures/vcr_cassettes/user_management/update_user/valid.yml