workos 1.6.1 → 2.1.1
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/Gemfile.lock +3 -3
- data/lib/workos/connection.rb +1 -1
- data/lib/workos/directory.rb +1 -1
- data/lib/workos/directory_sync.rb +29 -0
- data/lib/workos/profile.rb +1 -1
- data/lib/workos/sso.rb +38 -15
- data/lib/workos/types/connection_struct.rb +1 -1
- data/lib/workos/types/directory_struct.rb +1 -1
- data/lib/workos/types/profile_struct.rb +1 -1
- data/lib/workos/version.rb +1 -1
- data/lib/workos/webhooks.rb +8 -6
- data/spec/lib/workos/directory_sync_spec.rb +32 -0
- data/spec/lib/workos/sso_spec.rb +140 -2
- data/spec/lib/workos/webhooks_spec.rb +1 -1
- data/spec/support/fixtures/vcr_cassettes/directory_sync/get_directory_with_invalid_id.yml +83 -0
- data/spec/support/fixtures/vcr_cassettes/directory_sync/get_directory_with_valid_id.yml +84 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e98cbe7f34c4d550972ac7b4dc734e17ed9b2390b08898d2b20fdf5e69da71ea
|
4
|
+
data.tar.gz: c998bf772be7cc75e1730debd7efefa764d87676c62b325daf45784846ce3a12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01d4bcee2864d6a8b58e8cd3ffef78d77e11028bfbcd9005c4a2cecafaabe0cec97856f94b70aa9391dee50d08502ed8d7afa9456763d16a44f0fcc78a912694
|
7
|
+
data.tar.gz: ae83d9e5e204771f3d261a2f3135e077cc8b19d700ccf7984447e5536297ba65fba3779c3988daf612ce2c9624c9a825b8dd9b0e633e47c8839f3466a6837440
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
workos (1.
|
4
|
+
workos (2.1.1)
|
5
5
|
sorbet-runtime (~> 0.5)
|
6
6
|
|
7
7
|
GEM
|
@@ -60,7 +60,7 @@ GEM
|
|
60
60
|
simplecov_json_formatter (0.1.2)
|
61
61
|
sorbet (0.5.6388)
|
62
62
|
sorbet-static (= 0.5.6388)
|
63
|
-
sorbet-runtime (0.5.
|
63
|
+
sorbet-runtime (0.5.9528)
|
64
64
|
sorbet-static (0.5.6388-universal-darwin-14)
|
65
65
|
sorbet-static (0.5.6388-universal-darwin-15)
|
66
66
|
sorbet-static (0.5.6388-universal-darwin-16)
|
@@ -93,4 +93,4 @@ DEPENDENCIES
|
|
93
93
|
yard
|
94
94
|
|
95
95
|
BUNDLED WITH
|
96
|
-
2.2.
|
96
|
+
2.2.33
|
data/lib/workos/connection.rb
CHANGED
@@ -21,7 +21,7 @@ module WorkOS
|
|
21
21
|
@name = T.let(raw.name, String)
|
22
22
|
@connection_type = T.let(raw.connection_type, String)
|
23
23
|
@domains = T.let(raw.domains, Array)
|
24
|
-
@organization_id =
|
24
|
+
@organization_id = raw.organization_id
|
25
25
|
@state = T.let(raw.state, String)
|
26
26
|
@status = T.let(raw.status, String)
|
27
27
|
@created_at = T.let(raw.created_at, String)
|
data/lib/workos/directory.rb
CHANGED
@@ -20,7 +20,7 @@ module WorkOS
|
|
20
20
|
@domain = raw.domain
|
21
21
|
@type = T.let(raw.type, String)
|
22
22
|
@state = T.let(raw.state, String)
|
23
|
-
@organization_id =
|
23
|
+
@organization_id = raw.organization_id
|
24
24
|
@created_at = T.let(raw.created_at, String)
|
25
25
|
@updated_at = T.let(raw.updated_at, String)
|
26
26
|
end
|
@@ -53,6 +53,35 @@ module WorkOS
|
|
53
53
|
)
|
54
54
|
end
|
55
55
|
|
56
|
+
# Retrieve directory.
|
57
|
+
#
|
58
|
+
# @param [String] id Directory unique identifier
|
59
|
+
#
|
60
|
+
# @example
|
61
|
+
# WorkOS::SSO.get_directory(id: 'directory_01FK17DWRHH7APAFXT5B52PV0W')
|
62
|
+
# => #<WorkOS::Directory:0x00007fb6e4193d20
|
63
|
+
# @id="directory_01FK17DWRHH7APAFXT5B52PV0W",
|
64
|
+
# @name="Foo Corp",
|
65
|
+
# @domain="foo-corp.com",
|
66
|
+
# @type="okta scim v2.0",
|
67
|
+
# @state="linked",
|
68
|
+
# @organization_id="org_01F6Q6TFP7RD2PF6J03ANNWDKV",
|
69
|
+
# @created_at="2021-10-27T15:55:47.856Z",
|
70
|
+
# @updated_at="2021-10-27T16:03:43.990Z"
|
71
|
+
#
|
72
|
+
# @return [WorkOS::Directory]
|
73
|
+
sig { params(id: String).returns(WorkOS::Directory) }
|
74
|
+
def get_directory(id:)
|
75
|
+
request = get_request(
|
76
|
+
auth: true,
|
77
|
+
path: "/directories/#{id}",
|
78
|
+
)
|
79
|
+
|
80
|
+
response = execute_request(request: request)
|
81
|
+
|
82
|
+
WorkOS::Directory.new(response.body)
|
83
|
+
end
|
84
|
+
|
56
85
|
# Retrieve directory groups.
|
57
86
|
#
|
58
87
|
# @param [Hash] options An options hash
|
data/lib/workos/profile.rb
CHANGED
@@ -23,7 +23,7 @@ module WorkOS
|
|
23
23
|
@email = T.let(raw.email, String)
|
24
24
|
@first_name = raw.first_name
|
25
25
|
@last_name = raw.last_name
|
26
|
-
@organization_id =
|
26
|
+
@organization_id = raw.organization_id
|
27
27
|
@connection_id = T.let(raw.connection_id, String)
|
28
28
|
@connection_type = T.let(raw.connection_type, String)
|
29
29
|
@idp_id = raw.idp_id
|
data/lib/workos/sso.rb
CHANGED
@@ -21,23 +21,27 @@ module WorkOS
|
|
21
21
|
# Generate an Oauth2 authorization URL where your users will
|
22
22
|
# authenticate using the configured SSO Identity Provider.
|
23
23
|
#
|
24
|
+
# @param [String] redirect_uri The URI where users are directed
|
25
|
+
# after completing the authentication step. Must match a
|
26
|
+
# configured redirect URI on your WorkOS dashboard.
|
27
|
+
# @param [String] client_id The WorkOS client ID for the environment
|
28
|
+
# where you've configured your SSO connection.
|
24
29
|
# @param [String] domain The domain for the relevant SSO Connection
|
25
|
-
# configured on your WorkOS dashboard. One of provider
|
26
|
-
# required
|
30
|
+
# configured on your WorkOS dashboard. One of provider, domain,
|
31
|
+
# connection, or organization is required.
|
32
|
+
# The domain is deprecated.
|
27
33
|
# @param [String] provider A provider name for an Identity Provider
|
28
|
-
# configured on your WorkOS dashboard. Only '
|
34
|
+
# configured on your WorkOS dashboard. Only 'GoogleOAuth' and
|
35
|
+
# 'MicrosoftOAuth' are supported.
|
29
36
|
# @param [String] connection The ID for a Connection configured on
|
30
37
|
# WorkOS.
|
31
|
-
# @param [String]
|
32
|
-
#
|
33
|
-
# @param [String]
|
34
|
-
# after completing the authentication step. Must match a
|
35
|
-
# configured redirect URI on your WorkOS dashboard.
|
36
|
-
# @param [String] state An aribtrary state object
|
38
|
+
# @param [String] organization The ID for an Organization configured
|
39
|
+
# on WorkOS.
|
40
|
+
# @param [String] state An arbitrary state object
|
37
41
|
# that is preserved and available to the client in the response.
|
38
42
|
# @example
|
39
43
|
# WorkOS::SSO.authorization_url(
|
40
|
-
#
|
44
|
+
# connection: 'conn_123',
|
41
45
|
# client_id: 'project_01DG5TGK363GRVXP3ZS40WNGEZ',
|
42
46
|
# redirect_uri: 'https://workos.com/callback',
|
43
47
|
# state: {
|
@@ -45,19 +49,23 @@ module WorkOS
|
|
45
49
|
# }.to_s
|
46
50
|
# )
|
47
51
|
#
|
48
|
-
# => "https://api.workos.com/sso/authorize?
|
52
|
+
# => "https://api.workos.com/sso/authorize?connection=conn_123" \
|
49
53
|
# "&client_id=project_01DG5TGK363GRVXP3ZS40WNGEZ" \
|
50
54
|
# "&redirect_uri=https%3A%2F%2Fworkos.com%2Fcallback&" \
|
51
55
|
# "response_type=code&state=%7B%3Anext_page%3D%3E%22%2Fdocs%22%7D"
|
52
56
|
#
|
53
57
|
# @return [String]
|
58
|
+
# rubocop:disable Metrics/MethodLength, Metrics/ParameterLists
|
54
59
|
sig do
|
55
60
|
params(
|
56
61
|
redirect_uri: String,
|
57
62
|
client_id: T.nilable(String),
|
58
63
|
domain: T.nilable(String),
|
64
|
+
domain_hint: T.nilable(String),
|
65
|
+
login_hint: T.nilable(String),
|
59
66
|
provider: T.nilable(String),
|
60
67
|
connection: T.nilable(String),
|
68
|
+
organization: T.nilable(String),
|
61
69
|
state: T.nilable(String),
|
62
70
|
).returns(String)
|
63
71
|
end
|
@@ -65,14 +73,23 @@ module WorkOS
|
|
65
73
|
redirect_uri:,
|
66
74
|
client_id: nil,
|
67
75
|
domain: nil,
|
76
|
+
domain_hint: nil,
|
77
|
+
login_hint: nil,
|
68
78
|
provider: nil,
|
69
79
|
connection: nil,
|
80
|
+
organization: nil,
|
70
81
|
state: ''
|
71
82
|
)
|
83
|
+
if domain
|
84
|
+
warn '[DEPRECATION] `domain` is deprecated.
|
85
|
+
Please use `organization` instead.'
|
86
|
+
end
|
87
|
+
|
72
88
|
validate_authorization_url_arguments(
|
73
89
|
provider: provider,
|
74
90
|
domain: domain,
|
75
91
|
connection: connection,
|
92
|
+
organization: organization,
|
76
93
|
)
|
77
94
|
|
78
95
|
query = URI.encode_www_form({
|
@@ -81,12 +98,16 @@ module WorkOS
|
|
81
98
|
response_type: 'code',
|
82
99
|
state: state,
|
83
100
|
domain: domain,
|
101
|
+
domain_hint: domain_hint,
|
102
|
+
login_hint: login_hint,
|
84
103
|
provider: provider,
|
85
104
|
connection: connection,
|
105
|
+
organization: organization,
|
86
106
|
}.compact)
|
87
107
|
|
88
108
|
"https://#{WorkOS::API_HOSTNAME}/sso/authorize?#{query}"
|
89
109
|
end
|
110
|
+
# rubocop:enable Metrics/MethodLength, Metrics/ParameterLists
|
90
111
|
|
91
112
|
sig do
|
92
113
|
params(
|
@@ -229,16 +250,18 @@ module WorkOS
|
|
229
250
|
domain: T.nilable(String),
|
230
251
|
provider: T.nilable(String),
|
231
252
|
connection: T.nilable(String),
|
253
|
+
organization: T.nilable(String),
|
232
254
|
).void
|
233
255
|
end
|
234
256
|
def validate_authorization_url_arguments(
|
235
257
|
domain:,
|
236
258
|
provider:,
|
237
|
-
connection
|
259
|
+
connection:,
|
260
|
+
organization:
|
238
261
|
)
|
239
|
-
if [domain, provider, connection].all?(&:nil?)
|
240
|
-
raise ArgumentError, 'Either connection, domain,
|
241
|
-
'provider is required.'
|
262
|
+
if [domain, provider, connection, organization].all?(&:nil?)
|
263
|
+
raise ArgumentError, 'Either connection, domain, ' \
|
264
|
+
'provider, or organization is required.'
|
242
265
|
end
|
243
266
|
|
244
267
|
return unless provider && !PROVIDERS.include?(provider)
|
@@ -10,7 +10,7 @@ module WorkOS
|
|
10
10
|
const :name, String
|
11
11
|
const :connection_type, String
|
12
12
|
const :domains, T::Array[T.untyped]
|
13
|
-
const :organization_id, String
|
13
|
+
const :organization_id, T.nilable(String)
|
14
14
|
const :state, String
|
15
15
|
const :status, String
|
16
16
|
const :created_at, String
|
@@ -10,7 +10,7 @@ module WorkOS
|
|
10
10
|
const :email, String
|
11
11
|
const :first_name, T.nilable(String)
|
12
12
|
const :last_name, T.nilable(String)
|
13
|
-
const :organization_id, String
|
13
|
+
const :organization_id, T.nilable(String)
|
14
14
|
const :connection_id, String
|
15
15
|
const :connection_type, String
|
16
16
|
const :idp_id, T.nilable(String)
|
data/lib/workos/version.rb
CHANGED
data/lib/workos/webhooks.rb
CHANGED
@@ -65,7 +65,7 @@ module WorkOS
|
|
65
65
|
tolerance: Integer,
|
66
66
|
).returns(T::Boolean)
|
67
67
|
end
|
68
|
-
# rubocop:disable Metrics/MethodLength
|
68
|
+
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
69
69
|
def verify_header(
|
70
70
|
payload:,
|
71
71
|
sig_header:,
|
@@ -86,7 +86,9 @@ module WorkOS
|
|
86
86
|
)
|
87
87
|
end
|
88
88
|
|
89
|
-
|
89
|
+
timestamp_to_time = Time.at(timestamp.to_i / 1000)
|
90
|
+
|
91
|
+
if timestamp_to_time < Time.now - tolerance
|
90
92
|
raise WorkOS::SignatureVerificationError.new(
|
91
93
|
message: 'Timestamp outside the tolerance zone',
|
92
94
|
)
|
@@ -101,7 +103,7 @@ module WorkOS
|
|
101
103
|
|
102
104
|
true
|
103
105
|
end
|
104
|
-
# rubocop:enable Metrics/MethodLength
|
106
|
+
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
105
107
|
|
106
108
|
sig do
|
107
109
|
params(
|
@@ -122,12 +124,12 @@ module WorkOS
|
|
122
124
|
timestamp = timestamp.sub('t=', '')
|
123
125
|
signature_hash = signature_hash.sub('v1=', '')
|
124
126
|
|
125
|
-
[
|
127
|
+
[timestamp, signature_hash]
|
126
128
|
end
|
127
129
|
|
128
130
|
sig do
|
129
131
|
params(
|
130
|
-
timestamp:
|
132
|
+
timestamp: String,
|
131
133
|
payload: String,
|
132
134
|
secret: String,
|
133
135
|
).returns(String)
|
@@ -137,7 +139,7 @@ module WorkOS
|
|
137
139
|
payload:,
|
138
140
|
secret:
|
139
141
|
)
|
140
|
-
unhashed_string = "#{timestamp
|
142
|
+
unhashed_string = "#{timestamp}.#{payload}"
|
141
143
|
digest = OpenSSL::Digest.new('sha256')
|
142
144
|
OpenSSL::HMAC.hexdigest(digest, secret, unhashed_string)
|
143
145
|
end
|
@@ -143,6 +143,38 @@ describe WorkOS::DirectorySync do
|
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
|
+
describe '.get_directory' do
|
147
|
+
context 'with a valid id' do
|
148
|
+
it 'gets the directory details' do
|
149
|
+
VCR.use_cassette('directory_sync/get_directory_with_valid_id') do
|
150
|
+
directory = WorkOS::DirectorySync.get_directory(
|
151
|
+
id: 'directory_01FK17DWRHH7APAFXT5B52PV0W',
|
152
|
+
)
|
153
|
+
|
154
|
+
expect(directory.id).to eq('directory_01FK17DWRHH7APAFXT5B52PV0W')
|
155
|
+
expect(directory.name).to eq('Testing Active Attribute')
|
156
|
+
expect(directory.domain).to eq('example.me')
|
157
|
+
expect(directory.type).to eq('azure scim v2.0')
|
158
|
+
expect(directory.state).to eq('linked')
|
159
|
+
expect(directory.organization_id).to eq('org_01F6Q6TFP7RD2PF6J03ANNWDKV')
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
context 'with an invalid id' do
|
165
|
+
it 'raises an error' do
|
166
|
+
VCR.use_cassette('directory_sync/get_directory_with_invalid_id') do
|
167
|
+
expect do
|
168
|
+
WorkOS::DirectorySync.get_directory(id: 'invalid')
|
169
|
+
end.to raise_error(
|
170
|
+
WorkOS::APIError,
|
171
|
+
"Status 404, Directory not found: 'invalid'. - request ID: ",
|
172
|
+
)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
146
178
|
describe '.list_groups' do
|
147
179
|
context 'with no options' do
|
148
180
|
it 'raises an error' do
|
data/spec/lib/workos/sso_spec.rb
CHANGED
@@ -109,7 +109,145 @@ describe WorkOS::SSO do
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
|
-
context 'with
|
112
|
+
context 'with a domain' do
|
113
|
+
let(:args) do
|
114
|
+
{
|
115
|
+
domain: 'foo.com',
|
116
|
+
client_id: 'workos-proj-123',
|
117
|
+
redirect_uri: 'foo.com/auth/callback',
|
118
|
+
state: {
|
119
|
+
next_page: '/dashboard/edit',
|
120
|
+
}.to_s,
|
121
|
+
}
|
122
|
+
end
|
123
|
+
it 'returns a valid URL' do
|
124
|
+
authorization_url = described_class.authorization_url(**args)
|
125
|
+
|
126
|
+
expect(URI.parse(authorization_url)).to be_a URI
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'returns the expected hostname' do
|
130
|
+
authorization_url = described_class.authorization_url(**args)
|
131
|
+
|
132
|
+
expect(URI.parse(authorization_url).host).to eq(WorkOS::API_HOSTNAME)
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'returns the expected query string' do
|
136
|
+
authorization_url = described_class.authorization_url(**args)
|
137
|
+
|
138
|
+
expect(URI.parse(authorization_url).query).to eq(
|
139
|
+
'client_id=workos-proj-123&redirect_uri=foo.com%2Fauth%2Fcallback' \
|
140
|
+
'&response_type=code&state=%7B%3Anext_page%3D%3E%22%2Fdashboard%2F' \
|
141
|
+
'edit%22%7D&domain=foo.com',
|
142
|
+
)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
context 'with a domain_hint' do
|
147
|
+
let(:args) do
|
148
|
+
{
|
149
|
+
connection: 'connection_123',
|
150
|
+
domain_hint: 'foo.com',
|
151
|
+
client_id: 'workos-proj-123',
|
152
|
+
redirect_uri: 'foo.com/auth/callback',
|
153
|
+
state: {
|
154
|
+
next_page: '/dashboard/edit',
|
155
|
+
}.to_s,
|
156
|
+
}
|
157
|
+
end
|
158
|
+
it 'returns a valid URL' do
|
159
|
+
authorization_url = described_class.authorization_url(**args)
|
160
|
+
|
161
|
+
expect(URI.parse(authorization_url)).to be_a URI
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'returns the expected hostname' do
|
165
|
+
authorization_url = described_class.authorization_url(**args)
|
166
|
+
|
167
|
+
expect(URI.parse(authorization_url).host).to eq(WorkOS::API_HOSTNAME)
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'returns the expected query string' do
|
171
|
+
authorization_url = described_class.authorization_url(**args)
|
172
|
+
|
173
|
+
expect(URI.parse(authorization_url).query).to eq(
|
174
|
+
'client_id=workos-proj-123&redirect_uri=foo.com%2Fauth%2Fcallback' \
|
175
|
+
'&response_type=code&state=%7B%3Anext_page%3D%3E%22%2Fdashboard%2' \
|
176
|
+
'Fedit%22%7D&domain_hint=foo.com&connection=connection_123',
|
177
|
+
)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
context 'with a login_hint' do
|
182
|
+
let(:args) do
|
183
|
+
{
|
184
|
+
connection: 'connection_123',
|
185
|
+
login_hint: 'foo@workos.com',
|
186
|
+
client_id: 'workos-proj-123',
|
187
|
+
redirect_uri: 'foo.com/auth/callback',
|
188
|
+
state: {
|
189
|
+
next_page: '/dashboard/edit',
|
190
|
+
}.to_s,
|
191
|
+
}
|
192
|
+
end
|
193
|
+
it 'returns a valid URL' do
|
194
|
+
authorization_url = described_class.authorization_url(**args)
|
195
|
+
|
196
|
+
expect(URI.parse(authorization_url)).to be_a URI
|
197
|
+
end
|
198
|
+
|
199
|
+
it 'returns the expected hostname' do
|
200
|
+
authorization_url = described_class.authorization_url(**args)
|
201
|
+
|
202
|
+
expect(URI.parse(authorization_url).host).to eq(WorkOS::API_HOSTNAME)
|
203
|
+
end
|
204
|
+
|
205
|
+
it 'returns the expected query string' do
|
206
|
+
authorization_url = described_class.authorization_url(**args)
|
207
|
+
|
208
|
+
expect(URI.parse(authorization_url).query).to eq(
|
209
|
+
'client_id=workos-proj-123&redirect_uri=foo.com%2Fauth%2Fcallback' \
|
210
|
+
'&response_type=code&state=%7B%3Anext_page%3D%3E%22%2Fdashboard%2' \
|
211
|
+
'Fedit%22%7D&login_hint=foo%40workos.com&connection=connection_123',
|
212
|
+
)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
context 'with an organization' do
|
217
|
+
let(:args) do
|
218
|
+
{
|
219
|
+
organization: 'org_123',
|
220
|
+
client_id: 'workos-proj-123',
|
221
|
+
redirect_uri: 'foo.com/auth/callback',
|
222
|
+
state: {
|
223
|
+
next_page: '/dashboard/edit',
|
224
|
+
}.to_s,
|
225
|
+
}
|
226
|
+
end
|
227
|
+
it 'returns a valid URL' do
|
228
|
+
authorization_url = described_class.authorization_url(**args)
|
229
|
+
|
230
|
+
expect(URI.parse(authorization_url)).to be_a URI
|
231
|
+
end
|
232
|
+
|
233
|
+
it 'returns the expected hostname' do
|
234
|
+
authorization_url = described_class.authorization_url(**args)
|
235
|
+
|
236
|
+
expect(URI.parse(authorization_url).host).to eq(WorkOS::API_HOSTNAME)
|
237
|
+
end
|
238
|
+
|
239
|
+
it 'returns the expected query string' do
|
240
|
+
authorization_url = described_class.authorization_url(**args)
|
241
|
+
|
242
|
+
expect(URI.parse(authorization_url).query).to eq(
|
243
|
+
'client_id=workos-proj-123&redirect_uri=foo.com%2Fauth%2Fcallback' \
|
244
|
+
'&response_type=code&state=%7B%3Anext_page%3D%3E%22%2Fdashboard%2F' \
|
245
|
+
'edit%22%7D&organization=org_123',
|
246
|
+
)
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
context 'with neither connection, domain, provider, or organization' do
|
113
251
|
let(:args) do
|
114
252
|
{
|
115
253
|
client_id: 'workos-proj-123',
|
@@ -124,7 +262,7 @@ describe WorkOS::SSO do
|
|
124
262
|
described_class.authorization_url(**args)
|
125
263
|
end.to raise_error(
|
126
264
|
ArgumentError,
|
127
|
-
'Either connection, domain, or
|
265
|
+
'Either connection, domain, provider, or organization is required.',
|
128
266
|
)
|
129
267
|
end
|
130
268
|
end
|
@@ -177,7 +177,7 @@ describe WorkOS::Webhooks do
|
|
177
177
|
expect do
|
178
178
|
described_class.construct_event(
|
179
179
|
payload: @payload,
|
180
|
-
sig_header: "t
|
180
|
+
sig_header: "t=#{@timestamp.to_i - (200 * 1000)}, v1=#{@signature_hash}",
|
181
181
|
secret: @secret,
|
182
182
|
)
|
183
183
|
end.to raise_error(
|
@@ -0,0 +1,83 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.workos.com/directories/invalid
|
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.0.2; x86_64-darwin19; v1.6.1
|
18
|
+
Authorization:
|
19
|
+
- Bearer <API_KEY>
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 404
|
23
|
+
message: Not Found
|
24
|
+
headers:
|
25
|
+
Date:
|
26
|
+
- Sun, 07 Nov 2021 19:18:31 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Transfer-Encoding:
|
30
|
+
- chunked
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Content-Security-Policy:
|
34
|
+
- 'default-src ''self'';base-uri ''self'';block-all-mixed-content;font-src ''self''
|
35
|
+
https: data:;frame-ancestors ''self'';img-src ''self'' data:;object-src ''none'';script-src
|
36
|
+
''self'';script-src-attr ''none'';style-src ''self'' https: ''unsafe-inline'';upgrade-insecure-requests'
|
37
|
+
X-Dns-Prefetch-Control:
|
38
|
+
- 'off'
|
39
|
+
Expect-Ct:
|
40
|
+
- max-age=0
|
41
|
+
X-Frame-Options:
|
42
|
+
- SAMEORIGIN
|
43
|
+
Strict-Transport-Security:
|
44
|
+
- max-age=15552000; includeSubDomains
|
45
|
+
X-Download-Options:
|
46
|
+
- noopen
|
47
|
+
X-Content-Type-Options:
|
48
|
+
- nosniff
|
49
|
+
X-Permitted-Cross-Domain-Policies:
|
50
|
+
- none
|
51
|
+
Referrer-Policy:
|
52
|
+
- no-referrer
|
53
|
+
X-Xss-Protection:
|
54
|
+
- '0'
|
55
|
+
Vary:
|
56
|
+
- Origin, Accept-Encoding
|
57
|
+
Access-Control-Allow-Credentials:
|
58
|
+
- 'true'
|
59
|
+
X-Request-Id:
|
60
|
+
-
|
61
|
+
Etag:
|
62
|
+
- W/"5d-Sx4XoCfDLxkGIc0yAjSbi2ILYww"
|
63
|
+
Via:
|
64
|
+
- 1.1 vegur
|
65
|
+
Cf-Cache-Status:
|
66
|
+
- DYNAMIC
|
67
|
+
Report-To:
|
68
|
+
- '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=9UGS4Swz%2BHWvLOf0MGTCQbJyS0uBKnB72E77LfjybUN%2FXbJaDPBYfHnAUcgVM7JZbTefNquu4bG0Fw0edgQVoGnTK9OWPuO6fVKmo8XkF1G%2FNgibe8B715ZZje%2FZM7m3%2B9bEbNout5ArQfFyyQ%3D%3D"}],"group":"cf-nel","max_age":604800}'
|
69
|
+
Nel:
|
70
|
+
- '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}'
|
71
|
+
Server:
|
72
|
+
- cloudflare
|
73
|
+
Cf-Ray:
|
74
|
+
- 6aa8e86f7b5a66bf-DFW
|
75
|
+
Alt-Svc:
|
76
|
+
- h3=":443"; ma=86400, h3-29=":443"; ma=86400, h3-28=":443"; ma=86400, h3-27=":443";
|
77
|
+
ma=86400
|
78
|
+
body:
|
79
|
+
encoding: ASCII-8BIT
|
80
|
+
string: '{"message":"Directory not found: ''invalid''.","code":"entity_not_found","entity_id":"invalid"}'
|
81
|
+
http_version:
|
82
|
+
recorded_at: Sun, 07 Nov 2021 19:18:31 GMT
|
83
|
+
recorded_with: VCR 5.0.0
|
@@ -0,0 +1,84 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.workos.com/directories/directory_01FK17DWRHH7APAFXT5B52PV0W
|
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.0.2; x86_64-darwin19; v1.6.1
|
18
|
+
Authorization:
|
19
|
+
- Bearer <API_KEY>
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Date:
|
26
|
+
- Sun, 07 Nov 2021 19:18:31 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Transfer-Encoding:
|
30
|
+
- chunked
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Content-Security-Policy:
|
34
|
+
- 'default-src ''self'';base-uri ''self'';block-all-mixed-content;font-src ''self''
|
35
|
+
https: data:;frame-ancestors ''self'';img-src ''self'' data:;object-src ''none'';script-src
|
36
|
+
''self'';script-src-attr ''none'';style-src ''self'' https: ''unsafe-inline'';upgrade-insecure-requests'
|
37
|
+
X-Dns-Prefetch-Control:
|
38
|
+
- 'off'
|
39
|
+
Expect-Ct:
|
40
|
+
- max-age=0
|
41
|
+
X-Frame-Options:
|
42
|
+
- SAMEORIGIN
|
43
|
+
Strict-Transport-Security:
|
44
|
+
- max-age=15552000; includeSubDomains
|
45
|
+
X-Download-Options:
|
46
|
+
- noopen
|
47
|
+
X-Content-Type-Options:
|
48
|
+
- nosniff
|
49
|
+
X-Permitted-Cross-Domain-Policies:
|
50
|
+
- none
|
51
|
+
Referrer-Policy:
|
52
|
+
- no-referrer
|
53
|
+
X-Xss-Protection:
|
54
|
+
- '0'
|
55
|
+
Vary:
|
56
|
+
- Origin, Accept-Encoding
|
57
|
+
Access-Control-Allow-Credentials:
|
58
|
+
- 'true'
|
59
|
+
X-Request-Id:
|
60
|
+
- c63229f4-faa3-4693-a769-f132af1d156e
|
61
|
+
Etag:
|
62
|
+
- W/"149-gnrinkKr5pyIOSLENIObBLph9N0"
|
63
|
+
Via:
|
64
|
+
- 1.1 vegur
|
65
|
+
Cf-Cache-Status:
|
66
|
+
- DYNAMIC
|
67
|
+
Report-To:
|
68
|
+
- '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=8pe6lAa%2BE5FfpwjmgW1wU%2Fn%2BqfVS0xUHV0FKT%2Fvt%2FpQCa1A4nNwqR1hMyE9ytoi%2F3InXs3rP9ELYw%2FpJZ1Ow0uaNd3xoll7al5maCCPI1JWivjr%2Bxx6G1Otiw5iTIaAh3MXoP0pjUAnZVsf4bw%3D%3D"}],"group":"cf-nel","max_age":604800}'
|
69
|
+
Nel:
|
70
|
+
- '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}'
|
71
|
+
Server:
|
72
|
+
- cloudflare
|
73
|
+
Cf-Ray:
|
74
|
+
- 6aa8e86daa570b76-DFW
|
75
|
+
Alt-Svc:
|
76
|
+
- h3=":443"; ma=86400, h3-29=":443"; ma=86400, h3-28=":443"; ma=86400, h3-27=":443";
|
77
|
+
ma=86400
|
78
|
+
body:
|
79
|
+
encoding: ASCII-8BIT
|
80
|
+
string: '{"object":"directory","id":"directory_01FK17DWRHH7APAFXT5B52PV0W","organization_id":"org_01F6Q6TFP7RD2PF6J03ANNWDKV","name":"Testing
|
81
|
+
Active Attribute","external_key":"QArgyQQkq4G0MquM","type":"azure scim v2.0","state":"linked","created_at":"2021-10-27T15:55:47.856Z","updated_at":"2021-10-27T16:03:43.990Z","domain":"example.me"}'
|
82
|
+
http_version:
|
83
|
+
recorded_at: Sun, 07 Nov 2021 19:18:31 GMT
|
84
|
+
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: 1.
|
4
|
+
version: 2.1.1
|
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: 2022-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sorbet-runtime
|
@@ -289,6 +289,8 @@ files:
|
|
289
289
|
- spec/support/fixtures/vcr_cassettes/audit_trail/get_events.yml
|
290
290
|
- spec/support/fixtures/vcr_cassettes/base/execute_request_unauthenticated.yml
|
291
291
|
- spec/support/fixtures/vcr_cassettes/directory_sync/delete_directory.yml
|
292
|
+
- spec/support/fixtures/vcr_cassettes/directory_sync/get_directory_with_invalid_id.yml
|
293
|
+
- spec/support/fixtures/vcr_cassettes/directory_sync/get_directory_with_valid_id.yml
|
292
294
|
- spec/support/fixtures/vcr_cassettes/directory_sync/get_group.yml
|
293
295
|
- spec/support/fixtures/vcr_cassettes/directory_sync/get_group_with_invalid_id.yml
|
294
296
|
- spec/support/fixtures/vcr_cassettes/directory_sync/get_user.yml
|
@@ -362,7 +364,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
362
364
|
- !ruby/object:Gem::Version
|
363
365
|
version: '0'
|
364
366
|
requirements: []
|
365
|
-
rubygems_version: 3.
|
367
|
+
rubygems_version: 3.3.5
|
366
368
|
signing_key:
|
367
369
|
specification_version: 4
|
368
370
|
summary: API client for WorkOS
|
@@ -384,6 +386,8 @@ test_files:
|
|
384
386
|
- spec/support/fixtures/vcr_cassettes/audit_trail/get_events.yml
|
385
387
|
- spec/support/fixtures/vcr_cassettes/base/execute_request_unauthenticated.yml
|
386
388
|
- spec/support/fixtures/vcr_cassettes/directory_sync/delete_directory.yml
|
389
|
+
- spec/support/fixtures/vcr_cassettes/directory_sync/get_directory_with_invalid_id.yml
|
390
|
+
- spec/support/fixtures/vcr_cassettes/directory_sync/get_directory_with_valid_id.yml
|
387
391
|
- spec/support/fixtures/vcr_cassettes/directory_sync/get_group.yml
|
388
392
|
- spec/support/fixtures/vcr_cassettes/directory_sync/get_group_with_invalid_id.yml
|
389
393
|
- spec/support/fixtures/vcr_cassettes/directory_sync/get_user.yml
|