workos 7.1.1 → 7.1.2
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/.oagen-manifest.json +1 -1
- data/.release-please-manifest.json +1 -1
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +2 -2
- data/lib/workos/api_keys.rb +1 -1
- data/lib/workos/audit_logs.rb +2 -2
- data/lib/workos/authorization.rb +128 -116
- data/lib/workos/base_client.rb +6 -1
- data/lib/workos/encryptors/aes_gcm.rb +35 -3
- data/lib/workos/groups.rb +1 -1
- data/lib/workos/multi_factor_auth.rb +1 -1
- data/lib/workos/organization_domains.rb +1 -1
- data/lib/workos/radar.rb +2 -2
- data/lib/workos/sso.rb +2 -2
- data/lib/workos/user_management.rb +74 -65
- data/lib/workos/version.rb +1 -1
- data/lib/workos/webhooks.rb +1 -1
- data/rbi/workos/authorization.rbi +100 -26
- data/rbi/workos/user_management.rbi +60 -14
- data/test/workos/test_audit_logs.rb +2 -2
- data/test/workos/test_authorization.rb +86 -20
- data/test/workos/test_encryptors_aes_gcm.rb +21 -0
- data/test/workos/test_session.rb +68 -0
- data/test/workos/test_user_management.rb +44 -8
- data/test/workos/test_webhooks.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6e48d8fb142eca494c5b316c17dd940cfbb2244a5c1589a9b30cc7106f850631
|
|
4
|
+
data.tar.gz: 1fd7a0f9e75d74109e01e6a54546cf7f83155c78e64ea321e77d032e219a749c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 29c7c96477e7d66be140bee056673e9d5385beb15da8cad3011e9a3335d8d6ebcf902d9547c2188656ed0fdb0cdde724df79a6eb240507e501a46c6c0cded34e
|
|
7
|
+
data.tar.gz: 34592fb5ecd1d1e52f06338115f3740a02304f1c3d077c06a8038bb8bb009dd769073d2bff0bf782558a945bd3ff9b4270c868a1101ebf2c7ac6443bbaf735cd
|
data/.oagen-manifest.json
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [7.1.2](https://github.com/workos/workos-ruby/compare/v7.1.1...v7.1.2) (2026-05-06)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* decode legacy v6 sealed sessions on unseal ([#479](https://github.com/workos/workos-ruby/issues/479)) ([1d8b4aa](https://github.com/workos/workos-ruby/commit/1d8b4aaa26e77e6d7820feb7e2f81278a77b0cf4))
|
|
9
|
+
* replace parameter-group hashes with typed variant classes ([#473](https://github.com/workos/workos-ruby/issues/473)) ([a66c15b](https://github.com/workos/workos-ruby/commit/a66c15b6070ad8c26f0ca0b9ad7414f7b2ce8d8a))
|
|
10
|
+
* set canonical User-Agent header format ([#476](https://github.com/workos/workos-ruby/issues/476)) ([6728358](https://github.com/workos/workos-ruby/commit/67283581886a122f36d907229a71211665623219))
|
|
11
|
+
|
|
3
12
|
## [7.1.1](https://github.com/workos/workos-ruby/compare/v7.1.0...v7.1.1) (2026-04-29)
|
|
4
13
|
|
|
5
14
|
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
workos (7.1.
|
|
4
|
+
workos (7.1.2)
|
|
5
5
|
jwt (~> 3.1)
|
|
6
6
|
logger (~> 1.7)
|
|
7
7
|
zeitwerk (~> 2.6)
|
|
@@ -124,7 +124,7 @@ CHECKSUMS
|
|
|
124
124
|
unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42
|
|
125
125
|
unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f
|
|
126
126
|
webmock (3.26.2) sha256=774556f2ea6371846cca68c01769b2eac0d134492d21f6d0ab5dd643965a4c90
|
|
127
|
-
workos (7.1.
|
|
127
|
+
workos (7.1.2)
|
|
128
128
|
zeitwerk (2.7.5) sha256=d8da92128c09ea6ec62c949011b00ed4a20242b255293dd66bf41545398f73dd
|
|
129
129
|
|
|
130
130
|
BUNDLED WITH
|
data/lib/workos/api_keys.rb
CHANGED
data/lib/workos/audit_logs.rb
CHANGED
|
@@ -41,7 +41,7 @@ module WorkOS
|
|
|
41
41
|
)
|
|
42
42
|
body = {
|
|
43
43
|
"retention_period_in_days" => retention_period_in_days
|
|
44
|
-
}
|
|
44
|
+
}
|
|
45
45
|
response = @client.request(
|
|
46
46
|
method: :put,
|
|
47
47
|
path: "/organizations/#{WorkOS::Util.encode_path(id)}/audit_logs_retention",
|
|
@@ -189,7 +189,7 @@ module WorkOS
|
|
|
189
189
|
body = {
|
|
190
190
|
"organization_id" => organization_id,
|
|
191
191
|
"event" => event
|
|
192
|
-
}
|
|
192
|
+
}
|
|
193
193
|
response = @client.request(
|
|
194
194
|
method: :post,
|
|
195
195
|
path: "/audit_logs/events",
|
data/lib/workos/authorization.rb
CHANGED
|
@@ -6,6 +6,48 @@ require "json"
|
|
|
6
6
|
|
|
7
7
|
module WorkOS
|
|
8
8
|
class Authorization
|
|
9
|
+
# Identifies the resource target (by id variant).
|
|
10
|
+
#
|
|
11
|
+
# @!attribute [r] resource_id
|
|
12
|
+
# @return [String]
|
|
13
|
+
ResourceTargetById = Data.define(:resource_id)
|
|
14
|
+
|
|
15
|
+
# Identifies the resource target (by external id variant).
|
|
16
|
+
#
|
|
17
|
+
# @!attribute [r] resource_external_id
|
|
18
|
+
# @return [String]
|
|
19
|
+
# @!attribute [r] resource_type_slug
|
|
20
|
+
# @return [String]
|
|
21
|
+
ResourceTargetByExternalId = Data.define(:resource_external_id, :resource_type_slug)
|
|
22
|
+
|
|
23
|
+
# Identifies the parent resource (by id variant).
|
|
24
|
+
#
|
|
25
|
+
# @!attribute [r] parent_resource_id
|
|
26
|
+
# @return [String]
|
|
27
|
+
ParentResourceById = Data.define(:parent_resource_id)
|
|
28
|
+
|
|
29
|
+
# Identifies the parent resource (by external id variant).
|
|
30
|
+
#
|
|
31
|
+
# @!attribute [r] parent_resource_type_slug
|
|
32
|
+
# @return [String]
|
|
33
|
+
# @!attribute [r] parent_resource_external_id
|
|
34
|
+
# @return [String]
|
|
35
|
+
ParentResourceByExternalId = Data.define(:parent_resource_type_slug, :parent_resource_external_id)
|
|
36
|
+
|
|
37
|
+
# Identifies the parent (by id variant).
|
|
38
|
+
#
|
|
39
|
+
# @!attribute [r] parent_resource_id
|
|
40
|
+
# @return [String]
|
|
41
|
+
ParentById = Data.define(:parent_resource_id)
|
|
42
|
+
|
|
43
|
+
# Identifies the parent (by external id variant).
|
|
44
|
+
#
|
|
45
|
+
# @!attribute [r] parent_resource_type_slug
|
|
46
|
+
# @return [String]
|
|
47
|
+
# @!attribute [r] parent_external_id
|
|
48
|
+
# @return [String]
|
|
49
|
+
ParentByExternalId = Data.define(:parent_resource_type_slug, :parent_external_id)
|
|
50
|
+
|
|
9
51
|
def initialize(client)
|
|
10
52
|
@client = client
|
|
11
53
|
end
|
|
@@ -13,32 +55,26 @@ module WorkOS
|
|
|
13
55
|
# Check authorization
|
|
14
56
|
# @param organization_membership_id [String] The ID of the organization membership to check.
|
|
15
57
|
# @param permission_slug [String] The slug of the permission to check.
|
|
16
|
-
# @param
|
|
17
|
-
# @param resource_external_id [String, nil] The external ID of the resource. Required with `resource_type_slug`. Mutually exclusive with `resource_id`.
|
|
18
|
-
# @param resource_type_slug [String, nil] The slug of the resource type. Required with `resource_external_id`. Mutually exclusive with `resource_id`.
|
|
58
|
+
# @param resource_target [WorkOS::Authorization::ResourceTargetById, WorkOS::Authorization::ResourceTargetByExternalId] Identifies the resource target.
|
|
19
59
|
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
20
60
|
# @return [WorkOS::AuthorizationCheck]
|
|
21
61
|
def check(
|
|
22
62
|
organization_membership_id:,
|
|
23
63
|
permission_slug:,
|
|
24
64
|
resource_target:,
|
|
25
|
-
resource_id: nil,
|
|
26
|
-
resource_external_id: nil,
|
|
27
|
-
resource_type_slug: nil,
|
|
28
65
|
request_options: {}
|
|
29
66
|
)
|
|
30
67
|
body = {
|
|
31
|
-
"permission_slug" => permission_slug
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
body["
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
body["resource_type_slug"] = resource_target[:resource_type_slug]
|
|
68
|
+
"permission_slug" => permission_slug
|
|
69
|
+
}
|
|
70
|
+
case resource_target
|
|
71
|
+
when WorkOS::Authorization::ResourceTargetById
|
|
72
|
+
body["resource_id"] = resource_target.resource_id
|
|
73
|
+
when WorkOS::Authorization::ResourceTargetByExternalId
|
|
74
|
+
body["resource_external_id"] = resource_target.resource_external_id
|
|
75
|
+
body["resource_type_slug"] = resource_target.resource_type_slug
|
|
76
|
+
else
|
|
77
|
+
raise ArgumentError, "expected resource_target to be one of: WorkOS::Authorization::ResourceTargetById, WorkOS::Authorization::ResourceTargetByExternalId, got #{resource_target.class}"
|
|
42
78
|
end
|
|
43
79
|
response = @client.request(
|
|
44
80
|
method: :post,
|
|
@@ -59,6 +95,7 @@ module WorkOS
|
|
|
59
95
|
# @param limit [Integer, nil] Upper limit on the number of objects to return, between `1` and `100`.
|
|
60
96
|
# @param order [WorkOS::Types::AuthorizationOrder, nil] Order the results by the creation time. Supported values are `"asc"` (ascending), `"desc"` (descending), and `"normal"` (descending with reversed cursor semantics where `before` fetches older records and `after` fetches newer records). Defaults to descending.
|
|
61
97
|
# @param permission_slug [String] The permission slug to filter by. Only child resources where the organization membership has this permission are returned.
|
|
98
|
+
# @param parent_resource [WorkOS::Authorization::ParentResourceById, WorkOS::Authorization::ParentResourceByExternalId] Identifies the parent resource.
|
|
62
99
|
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
63
100
|
# @return [WorkOS::Types::ListStruct<WorkOS::AuthorizationResource>]
|
|
64
101
|
def list_resources_for_membership(
|
|
@@ -78,12 +115,14 @@ module WorkOS
|
|
|
78
115
|
"order" => order,
|
|
79
116
|
"permission_slug" => permission_slug
|
|
80
117
|
}.compact
|
|
81
|
-
case parent_resource
|
|
82
|
-
when
|
|
83
|
-
params["parent_resource_id"] = parent_resource
|
|
84
|
-
when
|
|
85
|
-
params["parent_resource_type_slug"] = parent_resource
|
|
86
|
-
params["parent_resource_external_id"] = parent_resource
|
|
118
|
+
case parent_resource
|
|
119
|
+
when WorkOS::Authorization::ParentResourceById
|
|
120
|
+
params["parent_resource_id"] = parent_resource.parent_resource_id
|
|
121
|
+
when WorkOS::Authorization::ParentResourceByExternalId
|
|
122
|
+
params["parent_resource_type_slug"] = parent_resource.parent_resource_type_slug
|
|
123
|
+
params["parent_resource_external_id"] = parent_resource.parent_resource_external_id
|
|
124
|
+
else
|
|
125
|
+
raise ArgumentError, "expected parent_resource to be one of: WorkOS::Authorization::ParentResourceById, WorkOS::Authorization::ParentResourceByExternalId, got #{parent_resource.class}"
|
|
87
126
|
end
|
|
88
127
|
response = @client.request(
|
|
89
128
|
method: :get,
|
|
@@ -265,32 +304,26 @@ module WorkOS
|
|
|
265
304
|
# Assign a role
|
|
266
305
|
# @param organization_membership_id [String] The ID of the organization membership.
|
|
267
306
|
# @param role_slug [String] The slug of the role to assign.
|
|
268
|
-
# @param
|
|
269
|
-
# @param resource_external_id [String, nil] The external ID of the resource. Required with `resource_type_slug`. Mutually exclusive with `resource_id`.
|
|
270
|
-
# @param resource_type_slug [String, nil] The resource type slug. Required with `resource_external_id`. Mutually exclusive with `resource_id`.
|
|
307
|
+
# @param resource_target [WorkOS::Authorization::ResourceTargetById, WorkOS::Authorization::ResourceTargetByExternalId] Identifies the resource target.
|
|
271
308
|
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
272
309
|
# @return [WorkOS::RoleAssignment]
|
|
273
310
|
def assign_role(
|
|
274
311
|
organization_membership_id:,
|
|
275
312
|
role_slug:,
|
|
276
313
|
resource_target:,
|
|
277
|
-
resource_id: nil,
|
|
278
|
-
resource_external_id: nil,
|
|
279
|
-
resource_type_slug: nil,
|
|
280
314
|
request_options: {}
|
|
281
315
|
)
|
|
282
316
|
body = {
|
|
283
|
-
"role_slug" => role_slug
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
body["
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
body["resource_type_slug"] = resource_target[:resource_type_slug]
|
|
317
|
+
"role_slug" => role_slug
|
|
318
|
+
}
|
|
319
|
+
case resource_target
|
|
320
|
+
when WorkOS::Authorization::ResourceTargetById
|
|
321
|
+
body["resource_id"] = resource_target.resource_id
|
|
322
|
+
when WorkOS::Authorization::ResourceTargetByExternalId
|
|
323
|
+
body["resource_external_id"] = resource_target.resource_external_id
|
|
324
|
+
body["resource_type_slug"] = resource_target.resource_type_slug
|
|
325
|
+
else
|
|
326
|
+
raise ArgumentError, "expected resource_target to be one of: WorkOS::Authorization::ResourceTargetById, WorkOS::Authorization::ResourceTargetByExternalId, got #{resource_target.class}"
|
|
294
327
|
end
|
|
295
328
|
response = @client.request(
|
|
296
329
|
method: :post,
|
|
@@ -307,34 +340,28 @@ module WorkOS
|
|
|
307
340
|
# Remove a role assignment
|
|
308
341
|
# @param organization_membership_id [String] The ID of the organization membership.
|
|
309
342
|
# @param role_slug [String] The slug of the role to remove.
|
|
310
|
-
# @param
|
|
311
|
-
# @param resource_external_id [String, nil] The external ID of the resource. Required with `resource_type_slug`. Mutually exclusive with `resource_id`.
|
|
312
|
-
# @param resource_type_slug [String, nil] The resource type slug. Required with `resource_external_id`. Mutually exclusive with `resource_id`.
|
|
343
|
+
# @param resource_target [WorkOS::Authorization::ResourceTargetById, WorkOS::Authorization::ResourceTargetByExternalId] Identifies the resource target.
|
|
313
344
|
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
314
345
|
# @return [void]
|
|
315
346
|
def remove_role(
|
|
316
347
|
organization_membership_id:,
|
|
317
348
|
role_slug:,
|
|
318
349
|
resource_target:,
|
|
319
|
-
resource_id: nil,
|
|
320
|
-
resource_external_id: nil,
|
|
321
|
-
resource_type_slug: nil,
|
|
322
350
|
request_options: {}
|
|
323
351
|
)
|
|
324
|
-
params = {}
|
|
325
|
-
case resource_target
|
|
326
|
-
when
|
|
327
|
-
params["resource_id"] = resource_target
|
|
328
|
-
when
|
|
329
|
-
params["resource_external_id"] = resource_target
|
|
330
|
-
params["resource_type_slug"] = resource_target
|
|
352
|
+
params = {}
|
|
353
|
+
case resource_target
|
|
354
|
+
when WorkOS::Authorization::ResourceTargetById
|
|
355
|
+
params["resource_id"] = resource_target.resource_id
|
|
356
|
+
when WorkOS::Authorization::ResourceTargetByExternalId
|
|
357
|
+
params["resource_external_id"] = resource_target.resource_external_id
|
|
358
|
+
params["resource_type_slug"] = resource_target.resource_type_slug
|
|
359
|
+
else
|
|
360
|
+
raise ArgumentError, "expected resource_target to be one of: WorkOS::Authorization::ResourceTargetById, WorkOS::Authorization::ResourceTargetByExternalId, got #{resource_target.class}"
|
|
331
361
|
end
|
|
332
362
|
body = {
|
|
333
|
-
"role_slug" => role_slug
|
|
334
|
-
|
|
335
|
-
"resource_external_id" => resource_external_id,
|
|
336
|
-
"resource_type_slug" => resource_type_slug
|
|
337
|
-
}.compact
|
|
363
|
+
"role_slug" => role_slug
|
|
364
|
+
}
|
|
338
365
|
@client.request(
|
|
339
366
|
method: :delete,
|
|
340
367
|
path: "/authorization/organization_memberships/#{WorkOS::Util.encode_path(organization_membership_id)}/role_assignments",
|
|
@@ -502,7 +529,7 @@ module WorkOS
|
|
|
502
529
|
)
|
|
503
530
|
body = {
|
|
504
531
|
"slug" => body_slug
|
|
505
|
-
}
|
|
532
|
+
}
|
|
506
533
|
response = @client.request(
|
|
507
534
|
method: :post,
|
|
508
535
|
path: "/authorization/organizations/#{WorkOS::Util.encode_path(organization_id)}/roles/#{WorkOS::Util.encode_path(slug)}/permissions",
|
|
@@ -529,7 +556,7 @@ module WorkOS
|
|
|
529
556
|
)
|
|
530
557
|
body = {
|
|
531
558
|
"permissions" => permissions
|
|
532
|
-
}
|
|
559
|
+
}
|
|
533
560
|
response = @client.request(
|
|
534
561
|
method: :put,
|
|
535
562
|
path: "/authorization/organizations/#{WorkOS::Util.encode_path(organization_id)}/roles/#{WorkOS::Util.encode_path(slug)}/permissions",
|
|
@@ -594,9 +621,7 @@ module WorkOS
|
|
|
594
621
|
# @param external_id [String] An identifier you provide to reference the resource in your system.
|
|
595
622
|
# @param name [String, nil] A display name for the resource.
|
|
596
623
|
# @param description [String, nil] An optional description of the resource.
|
|
597
|
-
# @param
|
|
598
|
-
# @param parent_resource_external_id [String, nil] The external ID of the parent resource. Required with `parent_resource_type_slug`. Mutually exclusive with `parent_resource_id`.
|
|
599
|
-
# @param parent_resource_type_slug [String, nil] The resource type slug of the parent resource. Required with `parent_resource_external_id`. Mutually exclusive with `parent_resource_id`.
|
|
624
|
+
# @param parent_resource [WorkOS::Authorization::ParentResourceById, WorkOS::Authorization::ParentResourceByExternalId, nil] Identifies the parent resource.
|
|
600
625
|
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
601
626
|
# @return [WorkOS::AuthorizationResource]
|
|
602
627
|
def update_resource_by_external_id(
|
|
@@ -605,26 +630,22 @@ module WorkOS
|
|
|
605
630
|
external_id:,
|
|
606
631
|
name: nil,
|
|
607
632
|
description: nil,
|
|
608
|
-
parent_resource_id: nil,
|
|
609
|
-
parent_resource_external_id: nil,
|
|
610
|
-
parent_resource_type_slug: nil,
|
|
611
633
|
parent_resource: nil,
|
|
612
634
|
request_options: {}
|
|
613
635
|
)
|
|
614
636
|
body = {
|
|
615
637
|
"name" => name,
|
|
616
|
-
"description" => description
|
|
617
|
-
"parent_resource_id" => parent_resource_id,
|
|
618
|
-
"parent_resource_external_id" => parent_resource_external_id,
|
|
619
|
-
"parent_resource_type_slug" => parent_resource_type_slug
|
|
638
|
+
"description" => description
|
|
620
639
|
}.compact
|
|
621
640
|
if parent_resource
|
|
622
|
-
case parent_resource
|
|
623
|
-
when
|
|
624
|
-
body["parent_resource_id"] = parent_resource
|
|
625
|
-
when
|
|
626
|
-
body["parent_resource_external_id"] = parent_resource
|
|
627
|
-
body["parent_resource_type_slug"] = parent_resource
|
|
641
|
+
case parent_resource
|
|
642
|
+
when WorkOS::Authorization::ParentResourceById
|
|
643
|
+
body["parent_resource_id"] = parent_resource.parent_resource_id
|
|
644
|
+
when WorkOS::Authorization::ParentResourceByExternalId
|
|
645
|
+
body["parent_resource_external_id"] = parent_resource.parent_resource_external_id
|
|
646
|
+
body["parent_resource_type_slug"] = parent_resource.parent_resource_type_slug
|
|
647
|
+
else
|
|
648
|
+
raise ArgumentError, "expected parent_resource to be one of: WorkOS::Authorization::ParentResourceById, WorkOS::Authorization::ParentResourceByExternalId, got #{parent_resource.class}"
|
|
628
649
|
end
|
|
629
650
|
end
|
|
630
651
|
response = @client.request(
|
|
@@ -736,6 +757,7 @@ module WorkOS
|
|
|
736
757
|
# @param resource_type_slug [String, nil] Filter resources by resource type slug.
|
|
737
758
|
# @param resource_external_id [String, nil] Filter resources by external ID.
|
|
738
759
|
# @param search [String, nil] Search resources by name.
|
|
760
|
+
# @param parent [WorkOS::Authorization::ParentById, WorkOS::Authorization::ParentByExternalId, nil] Identifies the parent.
|
|
739
761
|
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
740
762
|
# @return [WorkOS::Types::ListStruct<WorkOS::AuthorizationResource>]
|
|
741
763
|
def list_resources(
|
|
@@ -761,12 +783,14 @@ module WorkOS
|
|
|
761
783
|
"search" => search
|
|
762
784
|
}.compact
|
|
763
785
|
if parent
|
|
764
|
-
case parent
|
|
765
|
-
when
|
|
766
|
-
params["parent_resource_id"] = parent
|
|
767
|
-
when
|
|
768
|
-
params["parent_resource_type_slug"] = parent
|
|
769
|
-
params["parent_external_id"] = parent
|
|
786
|
+
case parent
|
|
787
|
+
when WorkOS::Authorization::ParentById
|
|
788
|
+
params["parent_resource_id"] = parent.parent_resource_id
|
|
789
|
+
when WorkOS::Authorization::ParentByExternalId
|
|
790
|
+
params["parent_resource_type_slug"] = parent.parent_resource_type_slug
|
|
791
|
+
params["parent_external_id"] = parent.parent_external_id
|
|
792
|
+
else
|
|
793
|
+
raise ArgumentError, "expected parent to be one of: WorkOS::Authorization::ParentById, WorkOS::Authorization::ParentByExternalId, got #{parent.class}"
|
|
770
794
|
end
|
|
771
795
|
end
|
|
772
796
|
response = @client.request(
|
|
@@ -804,9 +828,7 @@ module WorkOS
|
|
|
804
828
|
# @param description [String, nil] An optional description of the resource.
|
|
805
829
|
# @param resource_type_slug [String] The slug of the resource type.
|
|
806
830
|
# @param organization_id [String] The ID of the organization this resource belongs to.
|
|
807
|
-
# @param
|
|
808
|
-
# @param parent_resource_external_id [String, nil] The external ID of the parent resource. Required with `parent_resource_type_slug`. Mutually exclusive with `parent_resource_id`.
|
|
809
|
-
# @param parent_resource_type_slug [String, nil] The resource type slug of the parent resource. Required with `parent_resource_external_id`. Mutually exclusive with `parent_resource_id`.
|
|
831
|
+
# @param parent_resource [WorkOS::Authorization::ParentResourceById, WorkOS::Authorization::ParentResourceByExternalId, nil] Identifies the parent resource.
|
|
810
832
|
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
811
833
|
# @return [WorkOS::AuthorizationResource]
|
|
812
834
|
def create_resource(
|
|
@@ -815,9 +837,6 @@ module WorkOS
|
|
|
815
837
|
resource_type_slug:,
|
|
816
838
|
organization_id:,
|
|
817
839
|
description: nil,
|
|
818
|
-
parent_resource_id: nil,
|
|
819
|
-
parent_resource_external_id: nil,
|
|
820
|
-
parent_resource_type_slug: nil,
|
|
821
840
|
parent_resource: nil,
|
|
822
841
|
request_options: {}
|
|
823
842
|
)
|
|
@@ -826,18 +845,17 @@ module WorkOS
|
|
|
826
845
|
"name" => name,
|
|
827
846
|
"description" => description,
|
|
828
847
|
"resource_type_slug" => resource_type_slug,
|
|
829
|
-
"organization_id" => organization_id
|
|
830
|
-
"parent_resource_id" => parent_resource_id,
|
|
831
|
-
"parent_resource_external_id" => parent_resource_external_id,
|
|
832
|
-
"parent_resource_type_slug" => parent_resource_type_slug
|
|
848
|
+
"organization_id" => organization_id
|
|
833
849
|
}.compact
|
|
834
850
|
if parent_resource
|
|
835
|
-
case parent_resource
|
|
836
|
-
when
|
|
837
|
-
body["parent_resource_id"] = parent_resource
|
|
838
|
-
when
|
|
839
|
-
body["parent_resource_external_id"] = parent_resource
|
|
840
|
-
body["parent_resource_type_slug"] = parent_resource
|
|
851
|
+
case parent_resource
|
|
852
|
+
when WorkOS::Authorization::ParentResourceById
|
|
853
|
+
body["parent_resource_id"] = parent_resource.parent_resource_id
|
|
854
|
+
when WorkOS::Authorization::ParentResourceByExternalId
|
|
855
|
+
body["parent_resource_external_id"] = parent_resource.parent_resource_external_id
|
|
856
|
+
body["parent_resource_type_slug"] = parent_resource.parent_resource_type_slug
|
|
857
|
+
else
|
|
858
|
+
raise ArgumentError, "expected parent_resource to be one of: WorkOS::Authorization::ParentResourceById, WorkOS::Authorization::ParentResourceByExternalId, got #{parent_resource.class}"
|
|
841
859
|
end
|
|
842
860
|
end
|
|
843
861
|
response = @client.request(
|
|
@@ -875,35 +893,29 @@ module WorkOS
|
|
|
875
893
|
# @param resource_id [String] The ID of the authorization resource.
|
|
876
894
|
# @param name [String, nil] A display name for the resource.
|
|
877
895
|
# @param description [String, nil] An optional description of the resource.
|
|
878
|
-
# @param
|
|
879
|
-
# @param parent_resource_external_id [String, nil] The external ID of the parent resource. Required with `parent_resource_type_slug`. Mutually exclusive with `parent_resource_id`.
|
|
880
|
-
# @param parent_resource_type_slug [String, nil] The resource type slug of the parent resource. Required with `parent_resource_external_id`. Mutually exclusive with `parent_resource_id`.
|
|
896
|
+
# @param parent_resource [WorkOS::Authorization::ParentResourceById, WorkOS::Authorization::ParentResourceByExternalId, nil] Identifies the parent resource.
|
|
881
897
|
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
882
898
|
# @return [WorkOS::AuthorizationResource]
|
|
883
899
|
def update_resource(
|
|
884
900
|
resource_id:,
|
|
885
901
|
name: nil,
|
|
886
902
|
description: nil,
|
|
887
|
-
parent_resource_id: nil,
|
|
888
|
-
parent_resource_external_id: nil,
|
|
889
|
-
parent_resource_type_slug: nil,
|
|
890
903
|
parent_resource: nil,
|
|
891
904
|
request_options: {}
|
|
892
905
|
)
|
|
893
906
|
body = {
|
|
894
907
|
"name" => name,
|
|
895
|
-
"description" => description
|
|
896
|
-
"parent_resource_id" => parent_resource_id,
|
|
897
|
-
"parent_resource_external_id" => parent_resource_external_id,
|
|
898
|
-
"parent_resource_type_slug" => parent_resource_type_slug
|
|
908
|
+
"description" => description
|
|
899
909
|
}.compact
|
|
900
910
|
if parent_resource
|
|
901
|
-
case parent_resource
|
|
902
|
-
when
|
|
903
|
-
body["parent_resource_id"] = parent_resource
|
|
904
|
-
when
|
|
905
|
-
body["parent_resource_external_id"] = parent_resource
|
|
906
|
-
body["parent_resource_type_slug"] = parent_resource
|
|
911
|
+
case parent_resource
|
|
912
|
+
when WorkOS::Authorization::ParentResourceById
|
|
913
|
+
body["parent_resource_id"] = parent_resource.parent_resource_id
|
|
914
|
+
when WorkOS::Authorization::ParentResourceByExternalId
|
|
915
|
+
body["parent_resource_external_id"] = parent_resource.parent_resource_external_id
|
|
916
|
+
body["parent_resource_type_slug"] = parent_resource.parent_resource_type_slug
|
|
917
|
+
else
|
|
918
|
+
raise ArgumentError, "expected parent_resource to be one of: WorkOS::Authorization::ParentResourceById, WorkOS::Authorization::ParentResourceByExternalId, got #{parent_resource.class}"
|
|
907
919
|
end
|
|
908
920
|
end
|
|
909
921
|
response = @client.request(
|
|
@@ -1102,7 +1114,7 @@ module WorkOS
|
|
|
1102
1114
|
)
|
|
1103
1115
|
body = {
|
|
1104
1116
|
"slug" => body_slug
|
|
1105
|
-
}
|
|
1117
|
+
}
|
|
1106
1118
|
response = @client.request(
|
|
1107
1119
|
method: :post,
|
|
1108
1120
|
path: "/authorization/roles/#{WorkOS::Util.encode_path(slug)}/permissions",
|
|
@@ -1127,7 +1139,7 @@ module WorkOS
|
|
|
1127
1139
|
)
|
|
1128
1140
|
body = {
|
|
1129
1141
|
"permissions" => permissions
|
|
1130
|
-
}
|
|
1142
|
+
}
|
|
1131
1143
|
response = @client.request(
|
|
1132
1144
|
method: :put,
|
|
1133
1145
|
path: "/authorization/roles/#{WorkOS::Util.encode_path(slug)}/permissions",
|
data/lib/workos/base_client.rb
CHANGED
|
@@ -34,7 +34,12 @@ module WorkOS
|
|
|
34
34
|
RETRY_BACKOFF_BASE = 0.5
|
|
35
35
|
LOG_SEVERITY = {debug: 0, info: 1, warn: 2, error: 3, unknown: 4}.freeze
|
|
36
36
|
|
|
37
|
-
USER_AGENT =
|
|
37
|
+
USER_AGENT = [
|
|
38
|
+
"WorkOS",
|
|
39
|
+
"#{defined?(::RUBY_ENGINE) ? ::RUBY_ENGINE : "ruby"}/#{RUBY_VERSION}",
|
|
40
|
+
RUBY_PLATFORM,
|
|
41
|
+
"v#{WorkOS::VERSION}"
|
|
42
|
+
].join("; ").freeze
|
|
38
43
|
|
|
39
44
|
attr_reader :api_key, :base_url, :client_id, :timeout, :max_retries, :logger, :log_level
|
|
40
45
|
|
|
@@ -27,6 +27,18 @@ module WorkOS
|
|
|
27
27
|
|
|
28
28
|
def unseal(sealed, key)
|
|
29
29
|
raw = Base64.decode64(sealed.to_s)
|
|
30
|
+
decode_v7(raw, key)
|
|
31
|
+
rescue ArgumentError, OpenSSL::Cipher::CipherError => original_error
|
|
32
|
+
begin
|
|
33
|
+
decode_old(raw, key)
|
|
34
|
+
rescue ArgumentError, OpenSSL::Cipher::CipherError
|
|
35
|
+
raise original_error
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def decode_v7(raw, key)
|
|
30
42
|
raise ArgumentError, "Sealed payload too short" if raw.bytesize < 1 + 12 + 16
|
|
31
43
|
version = raw.byteslice(0, 1).bytes.first
|
|
32
44
|
raise ArgumentError, "Unknown seal version: #{version}" unless version == SEAL_VERSION
|
|
@@ -37,7 +49,29 @@ module WorkOS
|
|
|
37
49
|
cipher.key = derive_key(key)
|
|
38
50
|
cipher.iv = iv
|
|
39
51
|
cipher.auth_tag = tag
|
|
40
|
-
|
|
52
|
+
|
|
53
|
+
parse_decoded(cipher.update(ciphertext) + cipher.final)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def decode_old(raw, key)
|
|
57
|
+
# v6 sealed sessions were Base64(iv + ciphertext + auth_tag) using the
|
|
58
|
+
# `encryptor` gem without the v7 version byte or key derivation.
|
|
59
|
+
raise ArgumentError, "Legacy sealed payload too short" if raw.bytesize < 12 + 16
|
|
60
|
+
|
|
61
|
+
iv = raw.byteslice(0, 12)
|
|
62
|
+
encrypted = raw.byteslice(12, raw.bytesize - 12)
|
|
63
|
+
ciphertext = encrypted.byteslice(0, encrypted.bytesize - 16)
|
|
64
|
+
tag = encrypted.byteslice(encrypted.bytesize - 16, 16)
|
|
65
|
+
|
|
66
|
+
cipher = OpenSSL::Cipher.new("aes-256-gcm").decrypt
|
|
67
|
+
cipher.key = key.to_s
|
|
68
|
+
cipher.iv = iv
|
|
69
|
+
cipher.auth_tag = tag
|
|
70
|
+
|
|
71
|
+
parse_decoded(cipher.update(ciphertext) + cipher.final)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def parse_decoded(decoded)
|
|
41
75
|
decoded.force_encoding(Encoding::UTF_8)
|
|
42
76
|
begin
|
|
43
77
|
JSON.parse(decoded)
|
|
@@ -46,8 +80,6 @@ module WorkOS
|
|
|
46
80
|
end
|
|
47
81
|
end
|
|
48
82
|
|
|
49
|
-
private
|
|
50
|
-
|
|
51
83
|
def derive_key(passphrase)
|
|
52
84
|
Digest::SHA256.digest(passphrase.to_s)
|
|
53
85
|
end
|
data/lib/workos/groups.rb
CHANGED
|
@@ -219,7 +219,7 @@ module WorkOS
|
|
|
219
219
|
)
|
|
220
220
|
body = {
|
|
221
221
|
"organization_membership_id" => organization_membership_id
|
|
222
|
-
}
|
|
222
|
+
}
|
|
223
223
|
response = @client.request(
|
|
224
224
|
method: :post,
|
|
225
225
|
path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/groups/#{WorkOS::Util.encode_path(group_id)}/organization-memberships",
|
data/lib/workos/radar.rb
CHANGED
|
@@ -91,7 +91,7 @@ module WorkOS
|
|
|
91
91
|
)
|
|
92
92
|
body = {
|
|
93
93
|
"entry" => entry
|
|
94
|
-
}
|
|
94
|
+
}
|
|
95
95
|
response = @client.request(
|
|
96
96
|
method: :post,
|
|
97
97
|
path: "/radar/lists/#{WorkOS::Util.encode_path(type)}/#{WorkOS::Util.encode_path(action)}",
|
|
@@ -118,7 +118,7 @@ module WorkOS
|
|
|
118
118
|
)
|
|
119
119
|
body = {
|
|
120
120
|
"entry" => entry
|
|
121
|
-
}
|
|
121
|
+
}
|
|
122
122
|
@client.request(
|
|
123
123
|
method: :delete,
|
|
124
124
|
path: "/radar/lists/#{WorkOS::Util.encode_path(type)}/#{WorkOS::Util.encode_path(action)}",
|
data/lib/workos/sso.rb
CHANGED
|
@@ -116,7 +116,7 @@ module WorkOS
|
|
|
116
116
|
)
|
|
117
117
|
body = {
|
|
118
118
|
"profile_id" => profile_id
|
|
119
|
-
}
|
|
119
|
+
}
|
|
120
120
|
response = @client.request(
|
|
121
121
|
method: :post,
|
|
122
122
|
path: "/sso/logout/authorize",
|
|
@@ -157,7 +157,7 @@ module WorkOS
|
|
|
157
157
|
"client_id" => request_options[:client_id] || @client.client_id,
|
|
158
158
|
"client_secret" => request_options[:api_key] || @client.api_key,
|
|
159
159
|
"code" => code
|
|
160
|
-
}
|
|
160
|
+
}
|
|
161
161
|
response = @client.request(
|
|
162
162
|
method: :post,
|
|
163
163
|
path: "/sso/token",
|