workos 5.20.0 → 5.21.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: dc1f97c76fdf489cb3be51bd9026dc515195c34aaf9810379bfe4773029aafc1
4
- data.tar.gz: 2176f6680ae6a7c46ca77824c7dcf2fbe91ca244986a05f7039a1d40265db881
3
+ metadata.gz: 44c2f0a70f0a653685d6e7a8ca2601b64c4a1ff43276680ff52d0fcd2c80f5b3
4
+ data.tar.gz: 1d3aa7e958196efbe79018014e2ffd5be229dc93812a60725d05a958afcd1c20
5
5
  SHA512:
6
- metadata.gz: 6bda209314485831a8237e381566472c5815dea3b727db277e2a06c3db1c06191da54dc59292ec37bd4415291ca78c7593ae4a78cad82775ce6ffb8eae6d0931
7
- data.tar.gz: fd199d57bd3e29e0bea6b21840597ae255db869c9815b6a06348a90c3d70532606732c999c8bef3caa2ba2900914c20b222b526c7e1a9b61c836f30f5e55d694
6
+ metadata.gz: f51ad812297b13109f943a23d15592991b14f2d1c18ba91505c4227fffc64c2ac7912c32df163e974eb95a1f8069b3289f33b1bf783c18e757ba56e7869717d7
7
+ data.tar.gz: 5a5428749ac62c22f4fa33db0ad5a491e262c01e445a8318210d09e654e6123a17dec582e9d8b54f09913f123679f1ebe8bc57a2fec7d032f690acf28d77b8a4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- workos (5.20.0)
4
+ workos (5.21.0)
5
5
  encryptor (~> 3.0)
6
6
  jwt (~> 2.8)
7
7
 
@@ -185,7 +185,14 @@ module WorkOS
185
185
 
186
186
  # Retrieve a list of roles for the given organization.
187
187
  #
188
- # @param [String] organizationId The ID of the organization to fetch roles for.
188
+ # @param [String] organization_id The ID of the organization to fetch roles for.
189
+ #
190
+ # @example
191
+ # WorkOS::Organizations.list_organization_roles(organization_id: 'org_01EHZNVPK3SFK441A1RGBFSHRT')
192
+ # => #<WorkOS::Types::ListStruct data=[#<WorkOS::Role id="role_123" name="Admin" slug="admin"
193
+ # permissions=["admin:all"] ...>] ...>
194
+ #
195
+ # @return [WorkOS::Types::ListStruct] - Collection of Role objects, each including permissions array
189
196
  def list_organization_roles(organization_id:)
190
197
  response = execute_request(
191
198
  request: get_request(
data/lib/workos/role.rb CHANGED
@@ -7,7 +7,7 @@ module WorkOS
7
7
  class Role
8
8
  include HashProvider
9
9
 
10
- attr_accessor :id, :name, :slug, :description, :type, :created_at, :updated_at
10
+ attr_accessor :id, :name, :slug, :description, :permissions, :type, :created_at, :updated_at
11
11
 
12
12
  def initialize(json)
13
13
  hash = JSON.parse(json, symbolize_names: true)
@@ -16,6 +16,7 @@ module WorkOS
16
16
  @name = hash[:name]
17
17
  @slug = hash[:slug]
18
18
  @description = hash[:description]
19
+ @permissions = hash[:permissions] || []
19
20
  @type = hash[:type]
20
21
  @created_at = hash[:created_at]
21
22
  @updated_at = hash[:updated_at]
@@ -27,6 +28,7 @@ module WorkOS
27
28
  name: name,
28
29
  slug: slug,
29
30
  description: description,
31
+ permissions: permissions,
30
32
  type: type,
31
33
  created_at: created_at,
32
34
  updated_at: updated_at,
data/lib/workos/user.rb CHANGED
@@ -8,7 +8,7 @@ module WorkOS
8
8
  include HashProvider
9
9
 
10
10
  attr_accessor :id, :email, :first_name, :last_name, :email_verified,
11
- :profile_picture_url, :last_sign_in_at, :created_at, :updated_at
11
+ :profile_picture_url, :external_id, :last_sign_in_at, :created_at, :updated_at
12
12
 
13
13
  def initialize(json)
14
14
  hash = JSON.parse(json, symbolize_names: true)
@@ -19,6 +19,7 @@ module WorkOS
19
19
  @last_name = hash[:last_name]
20
20
  @email_verified = hash[:email_verified]
21
21
  @profile_picture_url = hash[:profile_picture_url]
22
+ @external_id = hash[:external_id]
22
23
  @last_sign_in_at = hash[:last_sign_in_at]
23
24
  @created_at = hash[:created_at]
24
25
  @updated_at = hash[:updated_at]
@@ -32,6 +33,7 @@ module WorkOS
32
33
  last_name: last_name,
33
34
  email_verified: email_verified,
34
35
  profile_picture_url: profile_picture_url,
36
+ external_id: external_id,
35
37
  last_sign_in_at: last_sign_in_at,
36
38
  created_at: created_at,
37
39
  updated_at: updated_at,
@@ -222,6 +222,7 @@ module WorkOS
222
222
  # @param [String] first_name The user's first name.
223
223
  # @param [String] last_name The user's last name.
224
224
  # @param [Boolean] email_verified Whether the user's email address was previously verified.
225
+ # @param [String] external_id The users's external ID
225
226
  # @param [String] password The user's password.
226
227
  # @param [String] password_hash The user's hashed password.
227
228
  # @option [String] password_hash_type The algorithm originally used to hash the password.
@@ -234,6 +235,7 @@ module WorkOS
234
235
  first_name: nil,
235
236
  last_name: nil,
236
237
  email_verified: nil,
238
+ external_id: nil,
237
239
  password: nil,
238
240
  password_hash: nil,
239
241
  password_hash_type: nil
@@ -245,6 +247,7 @@ module WorkOS
245
247
  first_name: first_name,
246
248
  last_name: last_name,
247
249
  email_verified: email_verified,
250
+ external_id: external_id,
248
251
  password: password,
249
252
  password_hash: password_hash,
250
253
  password_hash_type: password_hash_type,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WorkOS
4
- VERSION = '5.20.0'
4
+ VERSION = '5.21.0'
5
5
  end
@@ -354,6 +354,48 @@ describe WorkOS::Organizations do
354
354
  expect(roles.list_metadata).to eq(expected_metadata)
355
355
  end
356
356
  end
357
+
358
+ it 'returns properly initialized Role objects with all attributes' do
359
+ VCR.use_cassette 'organization/list_organization_roles' do
360
+ roles = described_class.list_organization_roles(organization_id: 'org_01JEXP6Z3X7HE4CB6WQSH9ZAFE')
361
+
362
+ first_role = roles.data.first
363
+ expect(first_role).to be_a(WorkOS::Role)
364
+ expect(first_role.id).to eq('role_01HS1C7GRJE08PBR3M6Y0ZYGDZ')
365
+ expect(first_role.name).to eq('Admin')
366
+ expect(first_role.slug).to eq('admin')
367
+ expect(first_role.description).to eq('Write access to every resource available')
368
+ expect(first_role.permissions).to eq(['admin:all', 'read:users', 'write:users', 'manage:roles'])
369
+ expect(first_role.type).to eq('EnvironmentRole')
370
+ expect(first_role.created_at).to eq('2024-03-15T15:38:29.521Z')
371
+ expect(first_role.updated_at).to eq('2024-11-14T17:08:00.556Z')
372
+ end
373
+ end
374
+
375
+ it 'handles roles with empty permissions arrays' do
376
+ VCR.use_cassette 'organization/list_organization_roles' do
377
+ roles = described_class.list_organization_roles(organization_id: 'org_01JEXP6Z3X7HE4CB6WQSH9ZAFE')
378
+
379
+ platform_manager_role = roles.data.find { |role| role.slug == 'org-platform-manager' }
380
+ expect(platform_manager_role).to be_a(WorkOS::Role)
381
+ expect(platform_manager_role.permissions).to eq([])
382
+ end
383
+ end
384
+
385
+ it 'properly serializes Role objects including permissions' do
386
+ VCR.use_cassette 'organization/list_organization_roles' do
387
+ roles = described_class.list_organization_roles(organization_id: 'org_01JEXP6Z3X7HE4CB6WQSH9ZAFE')
388
+
389
+ billing_role = roles.data.find { |role| role.slug == 'billing' }
390
+ serialized = billing_role.to_json
391
+
392
+ expect(serialized[:id]).to eq('role_01JA8GJZRDSZEB9289DQXJ3N9Z')
393
+ expect(serialized[:name]).to eq('Billing Manager')
394
+ expect(serialized[:slug]).to eq('billing')
395
+ expect(serialized[:permissions]).to eq(['read:billing', 'write:billing'])
396
+ expect(serialized[:type]).to eq('EnvironmentRole')
397
+ end
398
+ end
357
399
  end
358
400
  end
359
401
  end
@@ -0,0 +1,142 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe WorkOS::Role do
4
+ describe '.initialize' do
5
+ context 'with full role data including permissions' do
6
+ it 'initializes all attributes correctly' do
7
+ role_json = {
8
+ id: 'role_01FAEAJCJ3P1Z6WP5Y9VQPN2XY',
9
+ name: 'Admin',
10
+ slug: 'admin',
11
+ description: 'Administrator role with full access',
12
+ permissions: ['read:users', 'write:users', 'admin:all'],
13
+ type: 'system',
14
+ created_at: '2022-05-13T17:45:31.732Z',
15
+ updated_at: '2022-07-13T17:45:42.618Z',
16
+ }.to_json
17
+
18
+ role = described_class.new(role_json)
19
+
20
+ expect(role.id).to eq('role_01FAEAJCJ3P1Z6WP5Y9VQPN2XY')
21
+ expect(role.name).to eq('Admin')
22
+ expect(role.slug).to eq('admin')
23
+ expect(role.description).to eq('Administrator role with full access')
24
+ expect(role.permissions).to eq(['read:users', 'write:users', 'admin:all'])
25
+ expect(role.type).to eq('system')
26
+ expect(role.created_at).to eq('2022-05-13T17:45:31.732Z')
27
+ expect(role.updated_at).to eq('2022-07-13T17:45:42.618Z')
28
+ end
29
+ end
30
+
31
+ context 'with role data without permissions' do
32
+ it 'initializes permissions as empty array' do
33
+ role_json = {
34
+ id: 'role_01FAEAJCJ3P1Z6WP5Y9VQPN2XY',
35
+ name: 'User',
36
+ slug: 'user',
37
+ description: 'Basic user role',
38
+ type: 'custom',
39
+ created_at: '2022-05-13T17:45:31.732Z',
40
+ updated_at: '2022-07-13T17:45:42.618Z',
41
+ }.to_json
42
+
43
+ role = described_class.new(role_json)
44
+
45
+ expect(role.id).to eq('role_01FAEAJCJ3P1Z6WP5Y9VQPN2XY')
46
+ expect(role.name).to eq('User')
47
+ expect(role.slug).to eq('user')
48
+ expect(role.description).to eq('Basic user role')
49
+ expect(role.permissions).to eq([])
50
+ expect(role.type).to eq('custom')
51
+ expect(role.created_at).to eq('2022-05-13T17:45:31.732Z')
52
+ expect(role.updated_at).to eq('2022-07-13T17:45:42.618Z')
53
+ end
54
+ end
55
+
56
+ context 'with role data with null permissions' do
57
+ it 'initializes permissions as empty array' do
58
+ role_json = {
59
+ id: 'role_01FAEAJCJ3P1Z6WP5Y9VQPN2XY',
60
+ name: 'User',
61
+ slug: 'user',
62
+ description: 'Basic user role',
63
+ permissions: nil,
64
+ type: 'custom',
65
+ created_at: '2022-05-13T17:45:31.732Z',
66
+ updated_at: '2022-07-13T17:45:42.618Z',
67
+ }.to_json
68
+
69
+ role = described_class.new(role_json)
70
+
71
+ expect(role.permissions).to eq([])
72
+ end
73
+ end
74
+
75
+ context 'with role data with empty permissions array' do
76
+ it 'preserves empty permissions array' do
77
+ role_json = {
78
+ id: 'role_01FAEAJCJ3P1Z6WP5Y9VQPN2XY',
79
+ name: 'User',
80
+ slug: 'user',
81
+ description: 'Basic user role',
82
+ permissions: [],
83
+ type: 'custom',
84
+ created_at: '2022-05-13T17:45:31.732Z',
85
+ updated_at: '2022-07-13T17:45:42.618Z',
86
+ }.to_json
87
+
88
+ role = described_class.new(role_json)
89
+
90
+ expect(role.permissions).to eq([])
91
+ end
92
+ end
93
+ end
94
+
95
+ describe '.to_json' do
96
+ context 'with role that has permissions' do
97
+ it 'includes permissions in serialized output' do
98
+ role_json = {
99
+ id: 'role_01FAEAJCJ3P1Z6WP5Y9VQPN2XY',
100
+ name: 'Admin',
101
+ slug: 'admin',
102
+ description: 'Administrator role',
103
+ permissions: ['read:all', 'write:all'],
104
+ type: 'system',
105
+ created_at: '2022-05-13T17:45:31.732Z',
106
+ updated_at: '2022-07-13T17:45:42.618Z',
107
+ }.to_json
108
+
109
+ role = described_class.new(role_json)
110
+ serialized = role.to_json
111
+
112
+ expect(serialized[:id]).to eq('role_01FAEAJCJ3P1Z6WP5Y9VQPN2XY')
113
+ expect(serialized[:name]).to eq('Admin')
114
+ expect(serialized[:slug]).to eq('admin')
115
+ expect(serialized[:description]).to eq('Administrator role')
116
+ expect(serialized[:permissions]).to eq(['read:all', 'write:all'])
117
+ expect(serialized[:type]).to eq('system')
118
+ expect(serialized[:created_at]).to eq('2022-05-13T17:45:31.732Z')
119
+ expect(serialized[:updated_at]).to eq('2022-07-13T17:45:42.618Z')
120
+ end
121
+ end
122
+
123
+ context 'with role that has no permissions' do
124
+ it 'includes empty permissions array in serialized output' do
125
+ role_json = {
126
+ id: 'role_01FAEAJCJ3P1Z6WP5Y9VQPN2XY',
127
+ name: 'User',
128
+ slug: 'user',
129
+ description: 'Basic user role',
130
+ type: 'custom',
131
+ created_at: '2022-05-13T17:45:31.732Z',
132
+ updated_at: '2022-07-13T17:45:42.618Z',
133
+ }.to_json
134
+
135
+ role = described_class.new(role_json)
136
+ serialized = role.to_json
137
+
138
+ expect(serialized[:permissions]).to eq([])
139
+ end
140
+ end
141
+ end
142
+ end
@@ -362,10 +362,12 @@ describe WorkOS::UserManagement do
362
362
  first_name: 'Jane',
363
363
  last_name: 'Doe',
364
364
  email_verified: false,
365
+ external_id: '123',
365
366
  )
366
367
  expect(user.first_name).to eq('Jane')
367
368
  expect(user.last_name).to eq('Doe')
368
369
  expect(user.email_verified).to eq(false)
370
+ expect(user.external_id).to eq('123')
369
371
  end
370
372
  end
371
373
 
@@ -70,13 +70,13 @@ http_interactions:
70
70
  encoding: ASCII-8BIT
71
71
  string:
72
72
  '{"object":"list","data":[{"object":"role","id":"role_01HS1C7GRJE08PBR3M6Y0ZYGDZ","description":"Write
73
- access to every resource available","name":"Admin","slug":"admin","type":"EnvironmentRole","created_at":"2024-03-15T15:38:29.521Z","updated_at":"2024-11-14T17:08:00.556Z"},{"object":"role","id":"role_01JA8GJZRDSZEB9289DQXJ3N9Z","description":"","name":"Billing
74
- Manager","slug":"billing","type":"EnvironmentRole","created_at":"2024-10-15T16:36:11.653Z","updated_at":"2024-12-19T21:27:01.286Z"},{"object":"role","id":"role_01HSBH4R6RX0V86S3R590NNZW2","description":"Developer
75
- role","name":"Developer","slug":"developer","type":"EnvironmentRole","created_at":"2024-03-19T14:16:46.038Z","updated_at":"2024-03-19T14:16:46.038Z"},{"object":"role","id":"role_01HS4GDWJ8T6NQPTX2D0R5KBHN","description":"Edit
76
- and view access to non-critical resources","name":"Editor","slug":"editor","type":"EnvironmentRole","created_at":"2024-03-16T20:49:35.815Z","updated_at":"2024-03-16T20:52:19.410Z"},{"object":"role","id":"role_01HRFZE22WS2MGX6EWAG2JX6NW","description":"The
77
- default user role","name":"Member","slug":"member","type":"EnvironmentRole","created_at":"2024-03-08T21:27:47.034Z","updated_at":"2024-08-14T00:27:46.265Z"},{"object":"role","id":"role_01JEYJ2Z5MYG0TZYTDF02MW11N","description":"Manage
78
- billing for organization.","name":"Billing manager","slug":"org-billing-manager","type":"OrganizationRole","created_at":"2024-12-12T23:08:28.712Z","updated_at":"2024-12-12T23:08:28.712Z"},{"object":"role","id":"role_01JF0B7MQ9X414WQRAQMQYE1GS","description":"","name":"Platform
79
- Manager","slug":"org-platform-manager","type":"OrganizationRole","created_at":"2024-12-13T15:47:10.692Z","updated_at":"2024-12-13T15:47:10.692Z"}]}'
73
+ access to every resource available","name":"Admin","slug":"admin","permissions":["admin:all","read:users","write:users","manage:roles"],"type":"EnvironmentRole","created_at":"2024-03-15T15:38:29.521Z","updated_at":"2024-11-14T17:08:00.556Z"},{"object":"role","id":"role_01JA8GJZRDSZEB9289DQXJ3N9Z","description":"","name":"Billing
74
+ Manager","slug":"billing","permissions":["read:billing","write:billing"],"type":"EnvironmentRole","created_at":"2024-10-15T16:36:11.653Z","updated_at":"2024-12-19T21:27:01.286Z"},{"object":"role","id":"role_01HSBH4R6RX0V86S3R590NNZW2","description":"Developer
75
+ role","name":"Developer","slug":"developer","permissions":["read:code","write:code","deploy:apps"],"type":"EnvironmentRole","created_at":"2024-03-19T14:16:46.038Z","updated_at":"2024-03-19T14:16:46.038Z"},{"object":"role","id":"role_01HS4GDWJ8T6NQPTX2D0R5KBHN","description":"Edit
76
+ and view access to non-critical resources","name":"Editor","slug":"editor","permissions":["read:content","write:content","publish:content"],"type":"EnvironmentRole","created_at":"2024-03-16T20:49:35.815Z","updated_at":"2024-03-16T20:52:19.410Z"},{"object":"role","id":"role_01HRFZE22WS2MGX6EWAG2JX6NW","description":"The
77
+ default user role","name":"Member","slug":"member","permissions":["read:basic"],"type":"EnvironmentRole","created_at":"2024-03-08T21:27:47.034Z","updated_at":"2024-08-14T00:27:46.265Z"},{"object":"role","id":"role_01JEYJ2Z5MYG0TZYTDF02MW11N","description":"Manage
78
+ billing for organization.","name":"Billing manager","slug":"org-billing-manager","permissions":["read:org:billing","write:org:billing"],"type":"OrganizationRole","created_at":"2024-12-12T23:08:28.712Z","updated_at":"2024-12-12T23:08:28.712Z"},{"object":"role","id":"role_01JF0B7MQ9X414WQRAQMQYE1GS","description":"","name":"Platform
79
+ Manager","slug":"org-platform-manager","permissions":[],"type":"OrganizationRole","created_at":"2024-12-13T15:47:10.692Z","updated_at":"2024-12-13T15:47:10.692Z"}]}'
80
80
  http_version:
81
81
  recorded_at: Mon, 23 Dec 2024 20:23:07 GMT
82
82
  recorded_with: VCR 5.0.0
@@ -5,7 +5,7 @@ http_interactions:
5
5
  uri: https://api.workos.com/user_management/users/user_01H7TVSKS45SDHN5V9XPSM6H44
6
6
  body:
7
7
  encoding: UTF-8
8
- string: '{"first_name":"Jane","last_name":"Doe","email_verified":false}'
8
+ string: '{"first_name":"Jane","last_name":"Doe","email_verified":false,"external_id":"123"}'
9
9
  headers:
10
10
  Content-Type:
11
11
  - application/json
@@ -76,7 +76,7 @@ http_interactions:
76
76
  - cloudflare
77
77
  body:
78
78
  encoding: ASCII-8BIT
79
- string: '{"object":"user","id":"user_01H7TVSKS45SDHN5V9XPSM6H44","email":"willman@blips.app","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}'
79
+ string: '{"object":"user","id":"user_01H7TVSKS45SDHN5V9XPSM6H44","email":"willman@blips.app","email_verified":false,"first_name":"Jane","last_name":"Doe","external_id":"123","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
80
  http_version:
81
81
  recorded_at: Fri, 25 Aug 2023 23:37:04 GMT
82
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.20.0
4
+ version: 5.21.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-06-23 00:00:00.000000000 Z
11
+ date: 2025-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: encryptor
@@ -197,6 +197,7 @@ files:
197
197
  - spec/lib/workos/organizations_spec.rb
198
198
  - spec/lib/workos/passwordless_spec.rb
199
199
  - spec/lib/workos/portal_spec.rb
200
+ - spec/lib/workos/role_spec.rb
200
201
  - spec/lib/workos/session_spec.rb
201
202
  - spec/lib/workos/sso_spec.rb
202
203
  - spec/lib/workos/user_management_spec.rb
@@ -421,6 +422,7 @@ test_files:
421
422
  - spec/lib/workos/organizations_spec.rb
422
423
  - spec/lib/workos/passwordless_spec.rb
423
424
  - spec/lib/workos/portal_spec.rb
425
+ - spec/lib/workos/role_spec.rb
424
426
  - spec/lib/workos/session_spec.rb
425
427
  - spec/lib/workos/sso_spec.rb
426
428
  - spec/lib/workos/user_management_spec.rb