workos 5.8.0 → 5.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/workos/client.rb +8 -0
- data/lib/workos/errors.rb +4 -0
- data/lib/workos/organizations.rb +26 -0
- data/lib/workos/role.rb +36 -0
- data/lib/workos/types/widget_scope.rb +13 -0
- data/lib/workos/types.rb +1 -0
- data/lib/workos/version.rb +1 -1
- data/lib/workos/widgets.rb +46 -0
- data/lib/workos.rb +3 -0
- data/spec/lib/workos/organizations_spec.rb +18 -0
- data/spec/lib/workos/user_management_spec.rb +14 -0
- data/spec/lib/workos/widgets_spec.rb +73 -0
- data/spec/support/fixtures/vcr_cassettes/organization/list_organization_roles.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_password/unverified.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/widgets/get_token.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/widgets/get_token_invalid_organization_id.yml +74 -0
- data/spec/support/fixtures/vcr_cassettes/widgets/get_token_invalid_user_id.yml +74 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83c350d6c017c0cf423adb02925391b3a5e11d622479d76073c3c6372e526105
|
4
|
+
data.tar.gz: 83a8e5700dc7a3d47d37a84de01f866997a260eeaf96c55fd40318a30195a7d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48bcc853e186de15ce9e71e98415d801e412540a43fe1711ab97264b3419ce7dc7c1ec6095411cc7093bcb788b02ab51efe4689c0a79993f921e037ce0a7954c
|
7
|
+
data.tar.gz: f52aec8320aa98bb11ec114ffccb51a82218c7581cac202f74facfe943e96633b90262a67c37ed0677c73f4f73bb3bdd77760a67471c80a18ca878e0d7dffb55
|
data/Gemfile.lock
CHANGED
data/lib/workos/client.rb
CHANGED
@@ -109,6 +109,14 @@ module WorkOS
|
|
109
109
|
http_status: http_status,
|
110
110
|
request_id: response['x-request-id'],
|
111
111
|
)
|
112
|
+
when 403
|
113
|
+
raise ForbiddenRequestError.new(
|
114
|
+
message: json['message'],
|
115
|
+
http_status: http_status,
|
116
|
+
request_id: response['x-request-id'],
|
117
|
+
code: json['code'],
|
118
|
+
data: json,
|
119
|
+
)
|
112
120
|
when 404
|
113
121
|
raise NotFoundError.new(
|
114
122
|
message: json['message'],
|
data/lib/workos/errors.rb
CHANGED
@@ -64,6 +64,10 @@ module WorkOS
|
|
64
64
|
# parameters.
|
65
65
|
class InvalidRequestError < WorkOSError; end
|
66
66
|
|
67
|
+
# ForbiddenError is raised when a request is forbidden, likely due to missing a step
|
68
|
+
# (i.e. verifying email ownership before authenticating).
|
69
|
+
class ForbiddenRequestError < WorkOSError; end
|
70
|
+
|
67
71
|
# SignatureVerificationError is raised when the signature verification for a
|
68
72
|
# webhook fails
|
69
73
|
class SignatureVerificationError < WorkOSError; end
|
data/lib/workos/organizations.rb
CHANGED
@@ -180,6 +180,32 @@ module WorkOS
|
|
180
180
|
response.is_a? Net::HTTPSuccess
|
181
181
|
end
|
182
182
|
|
183
|
+
# Retrieve a list of roles for the given organization.
|
184
|
+
#
|
185
|
+
# @param [String] organizationId The ID of the organization to fetch roles for.
|
186
|
+
def list_organization_roles(organization_id:)
|
187
|
+
response = execute_request(
|
188
|
+
request: get_request(
|
189
|
+
path: "/organizations/#{organization_id}/roles",
|
190
|
+
auth: true,
|
191
|
+
),
|
192
|
+
)
|
193
|
+
|
194
|
+
parsed_response = JSON.parse(response.body)
|
195
|
+
|
196
|
+
roles = parsed_response['data'].map do |role|
|
197
|
+
WorkOS::Role.new(role.to_json)
|
198
|
+
end
|
199
|
+
|
200
|
+
WorkOS::Types::ListStruct.new(
|
201
|
+
data: roles,
|
202
|
+
list_metadata: {
|
203
|
+
after: nil,
|
204
|
+
before: nil,
|
205
|
+
},
|
206
|
+
)
|
207
|
+
end
|
208
|
+
|
183
209
|
private
|
184
210
|
|
185
211
|
def check_and_raise_organization_error(response:)
|
data/lib/workos/role.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WorkOS
|
4
|
+
# The Role class provides a lightweight wrapper around
|
5
|
+
# a WorkOS Role resource. This class is not meant to be instantiated
|
6
|
+
# in user space, and is instantiated internally but exposed.
|
7
|
+
class Role
|
8
|
+
include HashProvider
|
9
|
+
|
10
|
+
attr_accessor :id, :name, :slug, :description, :type, :created_at, :updated_at
|
11
|
+
|
12
|
+
def initialize(json)
|
13
|
+
hash = JSON.parse(json, symbolize_names: true)
|
14
|
+
|
15
|
+
@id = hash[:id]
|
16
|
+
@name = hash[:name]
|
17
|
+
@slug = hash[:slug]
|
18
|
+
@description = hash[:description]
|
19
|
+
@type = hash[:type]
|
20
|
+
@created_at = hash[:created_at]
|
21
|
+
@updated_at = hash[:updated_at]
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_json(*)
|
25
|
+
{
|
26
|
+
id: id,
|
27
|
+
name: name,
|
28
|
+
slug: slug,
|
29
|
+
description: description,
|
30
|
+
type: type,
|
31
|
+
created_at: created_at,
|
32
|
+
updated_at: updated_at,
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WorkOS
|
4
|
+
module Types
|
5
|
+
# The WidgetScope constants are declarations of a fixed set of values for
|
6
|
+
# scopes while generating a widget token.
|
7
|
+
module WidgetScope
|
8
|
+
USERS_TABLE_MANAGE = 'widgets:users-table:manage'
|
9
|
+
|
10
|
+
ALL = [USERS_TABLE_MANAGE].freeze
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/workos/types.rb
CHANGED
data/lib/workos/version.rb
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'net/http'
|
4
|
+
|
5
|
+
module WorkOS
|
6
|
+
# The Widgets module provides resource methods for working with the Widgets APIs
|
7
|
+
module Widgets
|
8
|
+
class << self
|
9
|
+
include Client
|
10
|
+
|
11
|
+
WIDGET_SCOPES = WorkOS::Types::WidgetScope::ALL
|
12
|
+
|
13
|
+
# Generate a widget token.
|
14
|
+
#
|
15
|
+
# @param [String] organization_id The ID of the organization to generate the token for.
|
16
|
+
# @param [String] user_id The ID of the user to generate the token for.
|
17
|
+
# @param [WidgetScope[]] The scopes to generate the token for.
|
18
|
+
def get_token(organization_id:, user_id:, scopes:)
|
19
|
+
validate_scopes(scopes)
|
20
|
+
|
21
|
+
request = post_request(
|
22
|
+
auth: true,
|
23
|
+
body: {
|
24
|
+
organization_id: organization_id,
|
25
|
+
user_id: user_id,
|
26
|
+
scopes: scopes,
|
27
|
+
},
|
28
|
+
path: '/widgets/token',
|
29
|
+
)
|
30
|
+
|
31
|
+
response = execute_request(request: request)
|
32
|
+
|
33
|
+
JSON.parse(response.body)['token']
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def validate_scopes(scopes)
|
39
|
+
return if scopes.all? { |scope| WIDGET_SCOPES.include?(scope) }
|
40
|
+
|
41
|
+
raise ArgumentError, 'scopes contains an invalid value.' \
|
42
|
+
" Every item in `scopes` must be in #{WIDGET_SCOPES}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/workos.rb
CHANGED
@@ -71,6 +71,7 @@ module WorkOS
|
|
71
71
|
autoload :Profile, 'workos/profile'
|
72
72
|
autoload :ProfileAndToken, 'workos/profile_and_token'
|
73
73
|
autoload :RefreshAuthenticationResponse, 'workos/refresh_authentication_response'
|
74
|
+
autoload :Role, 'workos/role'
|
74
75
|
autoload :Session, 'workos/session'
|
75
76
|
autoload :SSO, 'workos/sso'
|
76
77
|
autoload :Types, 'workos/types'
|
@@ -81,11 +82,13 @@ module WorkOS
|
|
81
82
|
autoload :VerifyChallenge, 'workos/verify_challenge'
|
82
83
|
autoload :Webhook, 'workos/webhook'
|
83
84
|
autoload :Webhooks, 'workos/webhooks'
|
85
|
+
autoload :Widgets, 'workos/widgets'
|
84
86
|
|
85
87
|
# Errors
|
86
88
|
autoload :APIError, 'workos/errors'
|
87
89
|
autoload :AuthenticationError, 'workos/errors'
|
88
90
|
autoload :InvalidRequestError, 'workos/errors'
|
91
|
+
autoload :ForbiddenRequestError, 'workos/errors'
|
89
92
|
autoload :SignatureVerificationError, 'workos/errors'
|
90
93
|
autoload :TimeoutError, 'workos/errors'
|
91
94
|
autoload :NotFoundError, 'workos/errors'
|
@@ -323,4 +323,22 @@ describe WorkOS::Organizations do
|
|
323
323
|
end
|
324
324
|
end
|
325
325
|
end
|
326
|
+
|
327
|
+
describe '.list_organization_roles' do
|
328
|
+
context 'with no options' do
|
329
|
+
it 'returns roles for organization' do
|
330
|
+
expected_metadata = {
|
331
|
+
after: nil,
|
332
|
+
before: nil,
|
333
|
+
}
|
334
|
+
|
335
|
+
VCR.use_cassette 'organization/list_organization_roles' do
|
336
|
+
roles = described_class.list_organization_roles(organization_id: 'org_01JEXP6Z3X7HE4CB6WQSH9ZAFE')
|
337
|
+
|
338
|
+
expect(roles.data.size).to eq(7)
|
339
|
+
expect(roles.list_metadata).to eq(expected_metadata)
|
340
|
+
end
|
341
|
+
end
|
342
|
+
end
|
343
|
+
end
|
326
344
|
end
|
@@ -404,6 +404,20 @@ describe WorkOS::UserManagement do
|
|
404
404
|
end
|
405
405
|
end
|
406
406
|
end
|
407
|
+
|
408
|
+
context 'with an unverified user' do
|
409
|
+
it 'raises a ForbiddenRequestError' do
|
410
|
+
VCR.use_cassette('user_management/authenticate_with_password/unverified') do
|
411
|
+
expect do
|
412
|
+
WorkOS::UserManagement.authenticate_with_password(
|
413
|
+
email: 'unverified@workos.app',
|
414
|
+
password: '7YtYic00VWcXatPb',
|
415
|
+
client_id: 'client_123',
|
416
|
+
)
|
417
|
+
end.to raise_error(WorkOS::ForbiddenRequestError, /Email ownership must be verified before authentication/)
|
418
|
+
end
|
419
|
+
end
|
420
|
+
end
|
407
421
|
end
|
408
422
|
|
409
423
|
describe '.authenticate_with_code' do
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe WorkOS::Widgets do
|
4
|
+
it_behaves_like 'client'
|
5
|
+
|
6
|
+
describe '.get_token' do
|
7
|
+
let(:organization_id) { 'org_01JCP9G67MNAH0KC4B72XZ67M7' }
|
8
|
+
let(:user_id) { 'user_01JCP9H4SHS4N3J6XTKDT7JNPE' }
|
9
|
+
|
10
|
+
describe 'with a valid organization_id and user_id and scopes' do
|
11
|
+
it 'returns a widget token' do
|
12
|
+
VCR.use_cassette 'widgets/get_token' do
|
13
|
+
token = described_class.get_token(
|
14
|
+
organization_id: organization_id,
|
15
|
+
user_id: user_id,
|
16
|
+
scopes: ['widgets:users-table:manage'],
|
17
|
+
)
|
18
|
+
|
19
|
+
expect(token).to start_with('eyJhbGciOiJSUzI1NiIsImtpZ')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'with an invalid organization_id' do
|
25
|
+
it 'raises an error' do
|
26
|
+
VCR.use_cassette 'widgets/get_token_invalid_organization_id' do
|
27
|
+
expect do
|
28
|
+
described_class.get_token(
|
29
|
+
organization_id: 'bogus-id',
|
30
|
+
user_id: user_id,
|
31
|
+
scopes: ['widgets:users-table:manage'],
|
32
|
+
)
|
33
|
+
end.to raise_error(
|
34
|
+
WorkOS::NotFoundError,
|
35
|
+
/Organization not found: 'bogus-id'/,
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'with an invalid user_id' do
|
42
|
+
it 'raises an error' do
|
43
|
+
VCR.use_cassette 'widgets/get_token_invalid_user_id' do
|
44
|
+
expect do
|
45
|
+
described_class.get_token(
|
46
|
+
organization_id: organization_id,
|
47
|
+
user_id: 'bogus-id',
|
48
|
+
scopes: ['widgets:users-table:manage'],
|
49
|
+
)
|
50
|
+
end.to raise_error(
|
51
|
+
WorkOS::NotFoundError,
|
52
|
+
/User not found: 'bogus-id'/,
|
53
|
+
)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe 'with invalid scopes' do
|
59
|
+
it 'raises an error' do
|
60
|
+
expect do
|
61
|
+
described_class.get_token(
|
62
|
+
organization_id: organization_id,
|
63
|
+
user_id: user_id,
|
64
|
+
scopes: ['bogus-scope'],
|
65
|
+
)
|
66
|
+
end.to raise_error(
|
67
|
+
ArgumentError,
|
68
|
+
/scopes contains an invalid value/,
|
69
|
+
)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.workos.com/organizations/org_01JEXP6Z3X7HE4CB6WQSH9ZAFE/roles
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ""
|
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.3.6; arm64-darwin23; v5.9.0
|
18
|
+
Authorization:
|
19
|
+
- Bearer <API_KEY>
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Date:
|
26
|
+
- Mon, 23 Dec 2024 20:23:07 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Transfer-Encoding:
|
30
|
+
- chunked
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Cf-Ray:
|
34
|
+
- 8f6b114e5e60c96a-IAD
|
35
|
+
Cf-Cache-Status:
|
36
|
+
- DYNAMIC
|
37
|
+
Etag:
|
38
|
+
- W/"6b6-bZ2pS5djCBrbcATBSFlbZ90PHB8"
|
39
|
+
Strict-Transport-Security:
|
40
|
+
- max-age=15552000; includeSubDomains
|
41
|
+
Vary:
|
42
|
+
- Origin, Accept-Encoding
|
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
|
+
- a8db37d7-9244-4e2a-b183-b5e2a67d8104
|
65
|
+
X-Xss-Protection:
|
66
|
+
- "0"
|
67
|
+
Server:
|
68
|
+
- cloudflare
|
69
|
+
body:
|
70
|
+
encoding: ASCII-8BIT
|
71
|
+
string:
|
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"}]}'
|
80
|
+
http_version:
|
81
|
+
recorded_at: Mon, 23 Dec 2024 20:23:07 GMT
|
82
|
+
recorded_with: VCR 5.0.0
|
data/spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_password/unverified.yml
ADDED
@@ -0,0 +1,82 @@
|
|
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:
|
9
|
+
'{"client_id":"client_123","client_secret":"<API_KEY>","email":"unverified@workos.app","password":"7YtYic00VWcXatPb","ip_address":"200.240.210.16","user_agent":"Mozilla/5.0
|
10
|
+
(Macintosh; Intel Mac OS X 10_15_7) Chrome/108.0.0.0 Safari/537.36","grant_type":"password"}'
|
11
|
+
headers:
|
12
|
+
Content-Type:
|
13
|
+
- application/json
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
+
Accept:
|
17
|
+
- '*/*'
|
18
|
+
User-Agent:
|
19
|
+
- WorkOS; ruby/3.0.2; arm64-darwin21; v2.16.0
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 403
|
23
|
+
message: Email ownership must be verified before authentication.
|
24
|
+
headers:
|
25
|
+
Date:
|
26
|
+
- Tue, 29 Aug 2023 00:24:25 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Transfer-Encoding:
|
30
|
+
- chunked
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Cf-Ray:
|
34
|
+
- 7fe0a6a27b0bc39c-SEA
|
35
|
+
Cf-Cache-Status:
|
36
|
+
- DYNAMIC
|
37
|
+
Etag:
|
38
|
+
- W/"16e-hoaHaR0EhmAH7TaNBOF8B2OHJq4"
|
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
|
+
- 62990367-ddaf-46b3-a32f-38fc4f29d581
|
67
|
+
X-Xss-Protection:
|
68
|
+
- '0'
|
69
|
+
Set-Cookie:
|
70
|
+
- __cf_bm=IiwoT1XAlPdVWj334oRTocU7zZyvKgYw61o0UoA7GtE-1693268665-0-AZTn/iGDfGV6R5j3aj7lcPod7FB9P3cbHc9pD1oN/U5ZmnUYvpCecp6AL+8p/+/bMuwwGqXGNMSa/eIpa0TVm+I=;
|
71
|
+
path=/; expires=Tue, 29-Aug-23 00:54:25 GMT; domain=.workos.com; HttpOnly;
|
72
|
+
Secure; SameSite=None
|
73
|
+
- __cfruid=beafd87202de7b7d34fd4a1af55696cb5d19364d-1693268665; path=/; domain=.workos.com;
|
74
|
+
HttpOnly; Secure; SameSite=None
|
75
|
+
Server:
|
76
|
+
- cloudflare
|
77
|
+
body:
|
78
|
+
encoding: ASCII-8BIT
|
79
|
+
string: '{"code":"email_verification_required", "message":"Email ownership must be verified before authentication.", "email":"unverified@workos.app", "pending_authentication_token":"RWx94aFHwanPOebv7tKbBkJm0", "email_verification_id":"email_verification_01JG43A0WYAFAPHMNBV5XF2R4M"}'
|
80
|
+
http_version:
|
81
|
+
recorded_at: Tue, 29 Aug 2023 00:24:25 GMT
|
82
|
+
recorded_with: VCR 5.0.0
|
@@ -0,0 +1,82 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://api.workos.com/widgets/token
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"organization_id":"org_01JCP9G67MNAH0KC4B72XZ67M7","user_id":"user_01JCP9H4SHS4N3J6XTKDT7JNPE","scopes":["widgets:users-table:manage"]}'
|
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.3.6; arm64-darwin23; v5.8.0
|
18
|
+
Authorization:
|
19
|
+
- Bearer <API_KEY>
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 201
|
23
|
+
message: Created
|
24
|
+
headers:
|
25
|
+
Date:
|
26
|
+
- Thu, 14 Nov 2024 21:51:34 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Content-Length:
|
30
|
+
- '791'
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Cf-Ray:
|
34
|
+
- 8e2a394198f8c9b8-IAD
|
35
|
+
Cf-Cache-Status:
|
36
|
+
- DYNAMIC
|
37
|
+
Etag:
|
38
|
+
- W/"317-Nylo8f8lWbsA0UUWqqV59mFy5jo"
|
39
|
+
Strict-Transport-Security:
|
40
|
+
- max-age=15552000; includeSubDomains
|
41
|
+
Vary:
|
42
|
+
- Origin, Accept-Encoding
|
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
|
+
- bf98d35e-d9ca-437f-b937-150e937af0f1
|
65
|
+
X-Xss-Protection:
|
66
|
+
- '0'
|
67
|
+
Set-Cookie:
|
68
|
+
- __cf_bm=GsR9Veicl9ZRIR1pUSamJ5m95HmklSbWNwtyp_fSpB4-1731621094-1.0.1.1-VW09qjPlT4T.AGwnsHxe7p_A.Onr9Oe7YnxumCz7B9XmzqYbLz9fx7cF6Qtw3KW0PIshpAVkluIsGWSCJQ5AjQ;
|
69
|
+
path=/; expires=Thu, 14-Nov-24 22:21:34 GMT; domain=.workos.com; HttpOnly;
|
70
|
+
Secure; SameSite=None
|
71
|
+
- __cfruid=022c638e9216cb6be687ace27cb356d48cbd4256-1731621094; path=/; domain=.workos.com;
|
72
|
+
HttpOnly; Secure; SameSite=None
|
73
|
+
- _cfuvid=kczJ.JXlRroyPs5B7UjNUynSmsUjYTWP_jcLNj2iiuM-1731621094755-0.0.1.1-604800000;
|
74
|
+
path=/; domain=.workos.com; HttpOnly; Secure; SameSite=None
|
75
|
+
Server:
|
76
|
+
- cloudflare
|
77
|
+
body:
|
78
|
+
encoding: UTF-8
|
79
|
+
string: '{"token":"eyJhbGciOiJSUzI1NiIsImtpZCI6InNzb19vaWRjX2tleV9wYWlyXzAxSFY3SlpGWEtQOVhCQjc2NjY0TkdUQlpYIn0.eyJhdWQiOiJodHRwczovL2FwaS53b3Jrb3MuY29tIiwiaXNzIjoiaHR0cHM6Ly9hcGkud29ya29zLmNvbSIsInN1YiI6InVzZXJfMDFKQ1A5SDRTSFM0TjNKNlhUS0RUN0pOUEUiLCJqdGkiOiIwMUpDUEFKMUFHWDVESzFNM0hDQTk5MFM1SiIsIm9yZ19pZCI6Im9yZ18wMUpDUDlHNjdNTkFIMEtDNEI3MlhaNjdNNyIsInBlcm1pc3Npb25zIjpbInVzZXJzOm1hbmFnZSIsInVzZXJzOnZpZXciXSwiZXhwIjoxNzMxNjI0Njk0LCJpYXQiOjE3MzE2MjEwOTR9.CTYliFAGFjw-_Lyla-yVBOUAn1ZqU-J7aOdWhAW8fiEsNMz73Fb5nRACa0PFWBE3HK1a8waV-S5lBCGHyxgYOaew5URNnlYXVwlgpKwujHDrW47FrYpxkyxVovY9z9SqDDNRHWBqJM3mH_4Fn9jaHwAVT0SPJrJ7Q4-jxfTc0_sZMR7RVJaBIXPEU8og6Zwc84Gx-9A-mBUA3PPUXfaa8JrCr5OGc482vbD1rF5sjk0jx_FovHrlI3qRo5nkQ3_5WEi7LzdxSPviITxY1-dtm0HbeULz8IL7Ic5O4Ok4lB2c8s8XoZT1JqUMmEHfugkWyQ4juN5aHpmf6ux8cJSJWg"}'
|
80
|
+
http_version:
|
81
|
+
recorded_at: Thu, 14 Nov 2024 21:51:34 GMT
|
82
|
+
recorded_with: VCR 5.0.0
|
@@ -0,0 +1,74 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://api.workos.com/widgets/token
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"organization_id":"bogus-id","user_id":"user_01JCP9H4SHS4N3J6XTKDT7JNPE","scopes":["widgets:users-table:manage"]}'
|
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.3.6; arm64-darwin23; v5.8.0
|
18
|
+
Authorization:
|
19
|
+
- Bearer <API_KEY>
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 404
|
23
|
+
message: Not Found
|
24
|
+
headers:
|
25
|
+
Date:
|
26
|
+
- Thu, 14 Nov 2024 22:02:40 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Transfer-Encoding:
|
30
|
+
- chunked
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Cf-Ray:
|
34
|
+
- 8e2a49858b5a7fa2-IAD
|
35
|
+
Cf-Cache-Status:
|
36
|
+
- DYNAMIC
|
37
|
+
Etag:
|
38
|
+
- W/"62-XNhANyOqo4doKt47ORHxpVuFTYg"
|
39
|
+
Strict-Transport-Security:
|
40
|
+
- max-age=15552000; includeSubDomains
|
41
|
+
Vary:
|
42
|
+
- Origin, Accept-Encoding
|
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
|
+
- 3d383216-51fe-42cd-87e2-7fee32719353
|
65
|
+
X-Xss-Protection:
|
66
|
+
- '0'
|
67
|
+
Server:
|
68
|
+
- cloudflare
|
69
|
+
body:
|
70
|
+
encoding: ASCII-8BIT
|
71
|
+
string: '{"message":"Organization not found: ''bogus-id''.","code":"entity_not_found","entity_id":"bogus-id"}'
|
72
|
+
http_version:
|
73
|
+
recorded_at: Thu, 14 Nov 2024 22:02:40 GMT
|
74
|
+
recorded_with: VCR 5.0.0
|
@@ -0,0 +1,74 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://api.workos.com/widgets/token
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"organization_id":"org_01JCP9G67MNAH0KC4B72XZ67M7","user_id":"bogus-id","scopes":["widgets:users-table:manage"]}'
|
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.3.6; arm64-darwin23; v5.8.0
|
18
|
+
Authorization:
|
19
|
+
- Bearer <API_KEY>
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 404
|
23
|
+
message: Not Found
|
24
|
+
headers:
|
25
|
+
Date:
|
26
|
+
- Thu, 14 Nov 2024 22:02:46 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Transfer-Encoding:
|
30
|
+
- chunked
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Cf-Ray:
|
34
|
+
- 8e2a49a82b31c54f-IAD
|
35
|
+
Cf-Cache-Status:
|
36
|
+
- DYNAMIC
|
37
|
+
Etag:
|
38
|
+
- W/"5a-TOigA+IvFyAtHvUdIXFXZWRdn8I"
|
39
|
+
Strict-Transport-Security:
|
40
|
+
- max-age=15552000; includeSubDomains
|
41
|
+
Vary:
|
42
|
+
- Origin, Accept-Encoding
|
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
|
+
- 0aeb3b90-0fd7-4de9-8d76-3d0e340ed583
|
65
|
+
X-Xss-Protection:
|
66
|
+
- '0'
|
67
|
+
Server:
|
68
|
+
- cloudflare
|
69
|
+
body:
|
70
|
+
encoding: ASCII-8BIT
|
71
|
+
string: '{"message":"User not found: ''bogus-id''.","code":"entity_not_found","entity_id":"bogus-id"}'
|
72
|
+
http_version:
|
73
|
+
recorded_at: Thu, 14 Nov 2024 22:02:46 GMT
|
74
|
+
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.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- WorkOS
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: encryptor
|
@@ -165,6 +165,7 @@ files:
|
|
165
165
|
- lib/workos/profile.rb
|
166
166
|
- lib/workos/profile_and_token.rb
|
167
167
|
- lib/workos/refresh_authentication_response.rb
|
168
|
+
- lib/workos/role.rb
|
168
169
|
- lib/workos/session.rb
|
169
170
|
- lib/workos/sso.rb
|
170
171
|
- lib/workos/types.rb
|
@@ -172,6 +173,7 @@ files:
|
|
172
173
|
- lib/workos/types/list_struct.rb
|
173
174
|
- lib/workos/types/passwordless_session_struct.rb
|
174
175
|
- lib/workos/types/provider.rb
|
176
|
+
- lib/workos/types/widget_scope.rb
|
175
177
|
- lib/workos/user.rb
|
176
178
|
- lib/workos/user_and_token.rb
|
177
179
|
- lib/workos/user_management.rb
|
@@ -180,6 +182,7 @@ files:
|
|
180
182
|
- lib/workos/version.rb
|
181
183
|
- lib/workos/webhook.rb
|
182
184
|
- lib/workos/webhooks.rb
|
185
|
+
- lib/workos/widgets.rb
|
183
186
|
- spec/lib/workos/audit_logs_spec.rb
|
184
187
|
- spec/lib/workos/client.rb
|
185
188
|
- spec/lib/workos/configuration_spec.rb
|
@@ -194,6 +197,7 @@ files:
|
|
194
197
|
- spec/lib/workos/sso_spec.rb
|
195
198
|
- spec/lib/workos/user_management_spec.rb
|
196
199
|
- spec/lib/workos/webhooks_spec.rb
|
200
|
+
- spec/lib/workos/widgets_spec.rb
|
197
201
|
- spec/spec_helper.rb
|
198
202
|
- spec/support/fixtures/vcr_cassettes/audit_logs/create_event.yml
|
199
203
|
- spec/support/fixtures/vcr_cassettes/audit_logs/create_event_custom_idempotency_key.yml
|
@@ -264,6 +268,7 @@ files:
|
|
264
268
|
- spec/support/fixtures/vcr_cassettes/organization/get.yml
|
265
269
|
- spec/support/fixtures/vcr_cassettes/organization/get_invalid.yml
|
266
270
|
- spec/support/fixtures/vcr_cassettes/organization/list.yml
|
271
|
+
- spec/support/fixtures/vcr_cassettes/organization/list_organization_roles.yml
|
267
272
|
- spec/support/fixtures/vcr_cassettes/organization/update.yml
|
268
273
|
- spec/support/fixtures/vcr_cassettes/organization/update_without_name.yml
|
269
274
|
- spec/support/fixtures/vcr_cassettes/passwordless/create_session.yml
|
@@ -297,6 +302,7 @@ files:
|
|
297
302
|
- spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_organization_selection/invalid.yml
|
298
303
|
- spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_organization_selection/valid.yml
|
299
304
|
- spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_password/invalid.yml
|
305
|
+
- spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_password/unverified.yml
|
300
306
|
- spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_password/valid.yml
|
301
307
|
- spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_refresh_code/invalid.yml
|
302
308
|
- spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_refresh_token/valid.yml
|
@@ -364,6 +370,9 @@ files:
|
|
364
370
|
- spec/support/fixtures/vcr_cassettes/user_management/verify_email/invalid_code.yml
|
365
371
|
- spec/support/fixtures/vcr_cassettes/user_management/verify_email/invalid_magic_auth_challenge.yml
|
366
372
|
- spec/support/fixtures/vcr_cassettes/user_management/verify_email/valid.yml
|
373
|
+
- spec/support/fixtures/vcr_cassettes/widgets/get_token.yml
|
374
|
+
- spec/support/fixtures/vcr_cassettes/widgets/get_token_invalid_organization_id.yml
|
375
|
+
- spec/support/fixtures/vcr_cassettes/widgets/get_token_invalid_user_id.yml
|
367
376
|
- spec/support/profile.txt
|
368
377
|
- spec/support/shared_examples/client.rb
|
369
378
|
- spec/support/webhook_payload.txt
|
@@ -407,6 +416,7 @@ test_files:
|
|
407
416
|
- spec/lib/workos/sso_spec.rb
|
408
417
|
- spec/lib/workos/user_management_spec.rb
|
409
418
|
- spec/lib/workos/webhooks_spec.rb
|
419
|
+
- spec/lib/workos/widgets_spec.rb
|
410
420
|
- spec/spec_helper.rb
|
411
421
|
- spec/support/fixtures/vcr_cassettes/audit_logs/create_event.yml
|
412
422
|
- spec/support/fixtures/vcr_cassettes/audit_logs/create_event_custom_idempotency_key.yml
|
@@ -477,6 +487,7 @@ test_files:
|
|
477
487
|
- spec/support/fixtures/vcr_cassettes/organization/get.yml
|
478
488
|
- spec/support/fixtures/vcr_cassettes/organization/get_invalid.yml
|
479
489
|
- spec/support/fixtures/vcr_cassettes/organization/list.yml
|
490
|
+
- spec/support/fixtures/vcr_cassettes/organization/list_organization_roles.yml
|
480
491
|
- spec/support/fixtures/vcr_cassettes/organization/update.yml
|
481
492
|
- spec/support/fixtures/vcr_cassettes/organization/update_without_name.yml
|
482
493
|
- spec/support/fixtures/vcr_cassettes/passwordless/create_session.yml
|
@@ -510,6 +521,7 @@ test_files:
|
|
510
521
|
- spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_organization_selection/invalid.yml
|
511
522
|
- spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_organization_selection/valid.yml
|
512
523
|
- spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_password/invalid.yml
|
524
|
+
- spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_password/unverified.yml
|
513
525
|
- spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_password/valid.yml
|
514
526
|
- spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_refresh_code/invalid.yml
|
515
527
|
- spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_refresh_token/valid.yml
|
@@ -577,6 +589,9 @@ test_files:
|
|
577
589
|
- spec/support/fixtures/vcr_cassettes/user_management/verify_email/invalid_code.yml
|
578
590
|
- spec/support/fixtures/vcr_cassettes/user_management/verify_email/invalid_magic_auth_challenge.yml
|
579
591
|
- spec/support/fixtures/vcr_cassettes/user_management/verify_email/valid.yml
|
592
|
+
- spec/support/fixtures/vcr_cassettes/widgets/get_token.yml
|
593
|
+
- spec/support/fixtures/vcr_cassettes/widgets/get_token_invalid_organization_id.yml
|
594
|
+
- spec/support/fixtures/vcr_cassettes/widgets/get_token_invalid_user_id.yml
|
580
595
|
- spec/support/profile.txt
|
581
596
|
- spec/support/shared_examples/client.rb
|
582
597
|
- spec/support/webhook_payload.txt
|