workos 2.2.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/workos/challenge.rb +1 -0
- data/lib/workos/connection.rb +1 -0
- data/lib/workos/deprecated_hash_wrapper.rb +76 -0
- data/lib/workos/directory.rb +1 -0
- data/lib/workos/directory_group.rb +5 -2
- data/lib/workos/directory_sync.rb +8 -8
- data/lib/workos/directory_user.rb +4 -1
- data/lib/workos/factor.rb +1 -0
- data/lib/workos/hash_provider.rb +19 -0
- data/lib/workos/organization.rb +1 -0
- data/lib/workos/profile.rb +1 -0
- data/lib/workos/profile_and_token.rb +1 -0
- data/lib/workos/types/passwordless_session_struct.rb +2 -0
- data/lib/workos/types/verify_factor_struct.rb +1 -3
- data/lib/workos/verify_factor.rb +1 -0
- data/lib/workos/version.rb +1 -1
- data/lib/workos/webhook.rb +1 -0
- data/lib/workos.rb +2 -0
- data/spec/lib/workos/directory_sync_spec.rb +4 -0
- data/spec/lib/workos/mfa_spec.rb +31 -1
- data/spec/support/fixtures/vcr_cassettes/mfa/verify_factor_generic_valid_is_false.yml +82 -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: 286a2f14af16bfc7b9c77e7938c2b8d7366f4a03f9fca4c7892f85f60562e433
|
4
|
+
data.tar.gz: 8970807084e7022beb9bb1523c270e645c340e42e452d7f0d7ea0d64958cf1ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4d3af795ee51a5cb807fda2bdffc2217e0150ec2f4ffe51fb86daab6e376ecd240f03f1b204db2a72265ebc61d5a9c227a13924a262bb6cf7011ce9c87df177
|
7
|
+
data.tar.gz: a8977f9bff244978c9c1935e46a411e4e564a86ed51d7523780feab31212857771813190c523f64d5640f13b393ba5f5a3df3ced5729a7ad34df0cdfa3b6014e
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
workos (2.2.
|
4
|
+
workos (2.2.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.9944)
|
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)
|
data/lib/workos/challenge.rb
CHANGED
@@ -6,6 +6,7 @@ module WorkOS
|
|
6
6
|
# a WorkOS DirectoryUser resource. This class is not meant to be instantiated
|
7
7
|
# in DirectoryUser space, and is instantiated internally but exposed.
|
8
8
|
class Challenge
|
9
|
+
include HashProvider
|
9
10
|
extend T::Sig
|
10
11
|
|
11
12
|
attr_accessor :id, :object, :expires_at, :code, :authentication_factor_id, :updated_at, :created_at
|
data/lib/workos/connection.rb
CHANGED
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WorkOS
|
4
|
+
# A Temporary wrapper class for a Hash, currently the base class for
|
5
|
+
# WorOS::DirectoryGroup and WorkOS::DirectoryUser. Makes all the Hash
|
6
|
+
# methods available to those classes, but will also emit a deprecation
|
7
|
+
# warning whenever any of them are used.
|
8
|
+
#
|
9
|
+
# Once we deprecate Hash compatibility, this model can be deleted.
|
10
|
+
class DeprecatedHashWrapper < Hash
|
11
|
+
(public_instance_methods - Object.methods).each do |method_name|
|
12
|
+
define_method method_name do |*args, &block|
|
13
|
+
print_deprecation_warning(method_name)
|
14
|
+
super(*args, &block)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# call the original implementation of :replace in Hash,
|
19
|
+
# so we don't show the deprecation warning
|
20
|
+
def replace_without_warning(new_hash)
|
21
|
+
method(:replace).super_method&.call(new_hash)
|
22
|
+
end
|
23
|
+
|
24
|
+
def [](attribute_name)
|
25
|
+
usage = "#{object_name}.#{attribute_name}"
|
26
|
+
warning_message = "WARNING: The Hash style access for #{class_name} attributes is deprecated
|
27
|
+
and will be removed in a future version. Please use `#{usage}` or equivalent accessor.\n"
|
28
|
+
|
29
|
+
print_deprecation_warning('[]', warning_message)
|
30
|
+
|
31
|
+
super(attribute_name.to_sym)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def deprecation_warning(method_name)
|
37
|
+
usage = "#{object_name}.to_h.#{method_name}"
|
38
|
+
|
39
|
+
"WARNING: Hash compatibility for #{class_name} is deprecated and will be removed
|
40
|
+
in a future version. Please use `#{usage}` to access methods on the attribute Hash object.\n"
|
41
|
+
end
|
42
|
+
|
43
|
+
def print_deprecation_warning(method_name, warning_message = deprecation_warning(method_name))
|
44
|
+
if RUBY_VERSION > '3'
|
45
|
+
warn warning_message, category: :deprecated
|
46
|
+
else
|
47
|
+
warn warning_message
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def class_name
|
52
|
+
self.class.name
|
53
|
+
end
|
54
|
+
|
55
|
+
# We want to do class_name.demodulize.underscore here, but that's not available in Ruby 1.9, so
|
56
|
+
# implementing the demodulize and underscore methods here.
|
57
|
+
def object_name
|
58
|
+
i = class_name.rindex('::')
|
59
|
+
object_name = i ? class_name[(i + 2)..-1] : class_name
|
60
|
+
underscore(object_name)
|
61
|
+
end
|
62
|
+
|
63
|
+
def underscore(camel_cased_word)
|
64
|
+
return camel_cased_word.to_s unless /[A-Z-]|::/.match?(camel_cased_word)
|
65
|
+
|
66
|
+
word = camel_cased_word.to_s.gsub('::', '/')
|
67
|
+
word.gsub!(/(?:(?<=([A-Za-z\d]))|\b)((?=a)b)(?=\b|[^a-z])/) do
|
68
|
+
"#{Regexp.last_match(1) && '_'}#{Regexp.last_match(2).downcase}"
|
69
|
+
end
|
70
|
+
word.gsub!(/([A-Z]+)(?=[A-Z][a-z])|([a-z\d])(?=[A-Z])/) { (Regexp.last_match(1) || Regexp.last_match(2)) << '_' }
|
71
|
+
word.tr!('-', '_')
|
72
|
+
word.downcase!
|
73
|
+
word
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/lib/workos/directory.rb
CHANGED
@@ -6,6 +6,7 @@ module WorkOS
|
|
6
6
|
# a WorkOS Directory resource. This class is not meant to be instantiated
|
7
7
|
# in user space, and is instantiated internally but exposed.
|
8
8
|
class Directory
|
9
|
+
include HashProvider
|
9
10
|
extend T::Sig
|
10
11
|
|
11
12
|
attr_accessor :id, :domain, :name, :type, :state, :organization_id, :created_at, :updated_at
|
@@ -5,10 +5,11 @@ module WorkOS
|
|
5
5
|
# The DirectoryGroup class provides a lightweight wrapper around
|
6
6
|
# a WorkOS DirectoryGroup resource. This class is not meant to be instantiated
|
7
7
|
# in user space, and is instantiated internally but exposed.
|
8
|
-
class DirectoryGroup
|
8
|
+
class DirectoryGroup < DeprecatedHashWrapper
|
9
|
+
include HashProvider
|
9
10
|
extend T::Sig
|
10
11
|
|
11
|
-
attr_accessor :id, :name
|
12
|
+
attr_accessor :id, :name, :custom_attributes, :raw_attributes
|
12
13
|
|
13
14
|
sig { params(json: String).void }
|
14
15
|
def initialize(json)
|
@@ -16,6 +17,8 @@ module WorkOS
|
|
16
17
|
|
17
18
|
@id = T.let(raw.id, String)
|
18
19
|
@name = T.let(raw.name, String)
|
20
|
+
|
21
|
+
replace_without_warning(to_json)
|
19
22
|
end
|
20
23
|
|
21
24
|
def to_json(*)
|
@@ -96,7 +96,7 @@ module WorkOS
|
|
96
96
|
# @option options [String] after Pagination cursor to receive records
|
97
97
|
# before a provided Directory Group ID.
|
98
98
|
#
|
99
|
-
# @return [
|
99
|
+
# @return [WorkOS::DirectoryGroup]
|
100
100
|
sig do
|
101
101
|
params(
|
102
102
|
options: T::Hash[Symbol, String],
|
@@ -135,7 +135,7 @@ module WorkOS
|
|
135
135
|
# @option options [String] after Pagination cursor to receive records
|
136
136
|
# before a provided Directory User ID.
|
137
137
|
#
|
138
|
-
# @return [
|
138
|
+
# @return [WorkOS::DirectoryUser]
|
139
139
|
sig do
|
140
140
|
params(
|
141
141
|
options: T::Hash[Symbol, String],
|
@@ -165,8 +165,8 @@ module WorkOS
|
|
165
165
|
#
|
166
166
|
# @param [String] id The ID of the directory group.
|
167
167
|
#
|
168
|
-
# @return
|
169
|
-
sig { params(id: String).returns(
|
168
|
+
# @return WorkOS::DirectoryGroup
|
169
|
+
sig { params(id: String).returns(WorkOS::DirectoryGroup) }
|
170
170
|
def get_group(id)
|
171
171
|
response = execute_request(
|
172
172
|
request: get_request(
|
@@ -175,15 +175,15 @@ module WorkOS
|
|
175
175
|
),
|
176
176
|
)
|
177
177
|
|
178
|
-
|
178
|
+
::WorkOS::DirectoryGroup.new(response.body)
|
179
179
|
end
|
180
180
|
|
181
181
|
# Retrieve the directory user with the given ID.
|
182
182
|
#
|
183
183
|
# @param [String] id The ID of the directory user.
|
184
184
|
#
|
185
|
-
# @return
|
186
|
-
sig { params(id: String).returns(
|
185
|
+
# @return WorkOS::DirectoryUser
|
186
|
+
sig { params(id: String).returns(WorkOS::DirectoryUser) }
|
187
187
|
def get_user(id)
|
188
188
|
response = execute_request(
|
189
189
|
request: get_request(
|
@@ -192,7 +192,7 @@ module WorkOS
|
|
192
192
|
),
|
193
193
|
)
|
194
194
|
|
195
|
-
|
195
|
+
::WorkOS::DirectoryUser.new(response.body)
|
196
196
|
end
|
197
197
|
|
198
198
|
# Delete the directory with the given ID.
|
@@ -5,7 +5,8 @@ module WorkOS
|
|
5
5
|
# The DirectoryUser class provides a lightweight wrapper around
|
6
6
|
# a WorkOS DirectoryUser resource. This class is not meant to be instantiated
|
7
7
|
# in DirectoryUser space, and is instantiated internally but exposed.
|
8
|
-
class DirectoryUser
|
8
|
+
class DirectoryUser < DeprecatedHashWrapper
|
9
|
+
include HashProvider
|
9
10
|
extend T::Sig
|
10
11
|
|
11
12
|
attr_accessor :id, :idp_id, :emails, :first_name, :last_name, :username, :state,
|
@@ -26,6 +27,8 @@ module WorkOS
|
|
26
27
|
@groups = T.let(raw.groups, Array)
|
27
28
|
@custom_attributes = raw.custom_attributes
|
28
29
|
@raw_attributes = raw.raw_attributes
|
30
|
+
|
31
|
+
replace_without_warning(to_json)
|
29
32
|
end
|
30
33
|
# rubocop:enable Metrics/AbcSize
|
31
34
|
|
data/lib/workos/factor.rb
CHANGED
@@ -6,6 +6,7 @@ module WorkOS
|
|
6
6
|
# a WorkOS DirectoryUser resource. This class is not meant to be instantiated
|
7
7
|
# in DirectoryUser space, and is instantiated internally but exposed.
|
8
8
|
class Factor
|
9
|
+
include HashProvider
|
9
10
|
# rubocop:disable Metrics/AbcSize
|
10
11
|
extend T::Sig
|
11
12
|
attr_accessor :id, :environment_id, :object, :type, :sms, :totp, :updated_at, :created_at
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# typed: true
|
3
|
+
|
4
|
+
module WorkOS
|
5
|
+
# Module to include an explicit method for converting a model into a Hash containing
|
6
|
+
# its attributes. Default implementation will simply call to_json. Individual classes
|
7
|
+
# may override.
|
8
|
+
module HashProvider
|
9
|
+
include Kernel
|
10
|
+
|
11
|
+
def to_json(*)
|
12
|
+
raise 'Must be implemented by including class.'
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_h
|
16
|
+
to_json
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/workos/organization.rb
CHANGED
@@ -6,6 +6,7 @@ module WorkOS
|
|
6
6
|
# a WorkOS Organization resource. This class is not meant to be instantiated
|
7
7
|
# in user space, and is instantiated internally but exposed.
|
8
8
|
class Organization
|
9
|
+
include HashProvider
|
9
10
|
extend T::Sig
|
10
11
|
|
11
12
|
attr_accessor :id, :domains, :name, :allow_profiles_outside_organization, :created_at, :updated_at
|
data/lib/workos/profile.rb
CHANGED
@@ -7,9 +7,7 @@ module WorkOS
|
|
7
7
|
# for the Factor class
|
8
8
|
class VerifyFactorStruct < T::Struct
|
9
9
|
const :challenge, T.nilable(T::Hash[Symbol, Object])
|
10
|
-
const :valid, T
|
11
|
-
const :code, T.nilable(String)
|
12
|
-
const :message, T.nilable(String)
|
10
|
+
const :valid, T::Boolean
|
13
11
|
end
|
14
12
|
end
|
15
13
|
end
|
data/lib/workos/verify_factor.rb
CHANGED
data/lib/workos/version.rb
CHANGED
data/lib/workos/webhook.rb
CHANGED
data/lib/workos.rb
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
require 'workos/version'
|
5
5
|
require 'sorbet-runtime'
|
6
6
|
require 'json'
|
7
|
+
require 'workos/hash_provider'
|
7
8
|
|
8
9
|
# Use the WorkOS module to authenticate your
|
9
10
|
# requests to the WorkOS API. The gem will read
|
@@ -48,6 +49,7 @@ module WorkOS
|
|
48
49
|
autoload :Factor, 'workos/factor'
|
49
50
|
autoload :Challenge, 'workos/challenge'
|
50
51
|
autoload :VerifyFactor, 'workos/verify_factor'
|
52
|
+
autoload :DeprecatedHashWrapper, 'workos/deprecated_hash_wrapper'
|
51
53
|
|
52
54
|
|
53
55
|
# Errors
|
@@ -204,6 +204,7 @@ describe WorkOS::DirectorySync do
|
|
204
204
|
)
|
205
205
|
|
206
206
|
expect(groups.data.size).to eq(10)
|
207
|
+
expect(groups.data[0].name).to eq(groups.data[0]['name'])
|
207
208
|
end
|
208
209
|
end
|
209
210
|
end
|
@@ -332,6 +333,7 @@ describe WorkOS::DirectorySync do
|
|
332
333
|
)
|
333
334
|
|
334
335
|
expect(users.data.size).to eq(4)
|
336
|
+
expect(users.data[0].first_name).to eq(users.data[0]['first_name'])
|
335
337
|
end
|
336
338
|
end
|
337
339
|
end
|
@@ -440,6 +442,7 @@ describe WorkOS::DirectorySync do
|
|
440
442
|
)
|
441
443
|
|
442
444
|
expect(group['name']).to eq('Walrus')
|
445
|
+
expect(group.name).to eq('Walrus')
|
443
446
|
end
|
444
447
|
end
|
445
448
|
end
|
@@ -464,6 +467,7 @@ describe WorkOS::DirectorySync do
|
|
464
467
|
)
|
465
468
|
|
466
469
|
expect(user['first_name']).to eq('Logan')
|
470
|
+
expect(user.first_name).to eq('Logan')
|
467
471
|
end
|
468
472
|
end
|
469
473
|
end
|
data/spec/lib/workos/mfa_spec.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
|
4
4
|
describe WorkOS::MFA do
|
5
5
|
it_behaves_like 'client'
|
6
|
+
|
6
7
|
describe 'enroll_factor valid requests' do
|
7
8
|
context 'enroll factor using valid generic argument' do
|
8
9
|
it 'returns a valid factor object' do
|
@@ -14,6 +15,7 @@ describe WorkOS::MFA do
|
|
14
15
|
end
|
15
16
|
end
|
16
17
|
end
|
18
|
+
|
17
19
|
context 'enroll factor using valid totp arguments' do
|
18
20
|
it 'returns a valid factor object' do
|
19
21
|
VCR.use_cassette 'mfa/enroll_factor_totp_valid' do
|
@@ -26,6 +28,7 @@ describe WorkOS::MFA do
|
|
26
28
|
end
|
27
29
|
end
|
28
30
|
end
|
31
|
+
|
29
32
|
context 'enroll factor using valid sms arguments' do
|
30
33
|
it 'returns a valid factor object' do
|
31
34
|
VCR.use_cassette 'mfa/enroll_factor_sms_valid' do
|
@@ -38,6 +41,7 @@ describe WorkOS::MFA do
|
|
38
41
|
end
|
39
42
|
end
|
40
43
|
end
|
44
|
+
|
41
45
|
describe 'enroll_factor invalid responses' do
|
42
46
|
context 'enroll factor throws error if type is not sms or totp' do
|
43
47
|
it 'returns an error' do
|
@@ -52,6 +56,7 @@ describe WorkOS::MFA do
|
|
52
56
|
)
|
53
57
|
end
|
54
58
|
end
|
59
|
+
|
55
60
|
context 'enroll factor throws error if type is not sms or totp' do
|
56
61
|
it 'returns an error' do
|
57
62
|
expect do
|
@@ -78,6 +83,7 @@ describe WorkOS::MFA do
|
|
78
83
|
end
|
79
84
|
end
|
80
85
|
end
|
86
|
+
|
81
87
|
describe 'challenge factor with valid request arguments' do
|
82
88
|
context 'challenge with totp' do
|
83
89
|
it 'returns challenge factor object for totp' do
|
@@ -89,6 +95,7 @@ describe WorkOS::MFA do
|
|
89
95
|
end
|
90
96
|
end
|
91
97
|
end
|
98
|
+
|
92
99
|
context 'challenge with sms' do
|
93
100
|
it 'returns a challenge factor object for sms' do
|
94
101
|
VCR.use_cassette 'mfa/challenge_factor_sms_valid' do
|
@@ -100,6 +107,7 @@ describe WorkOS::MFA do
|
|
100
107
|
end
|
101
108
|
end
|
102
109
|
end
|
110
|
+
|
103
111
|
context 'challenge with generic' do
|
104
112
|
it 'returns a valid challenge factor object for generic otp' do
|
105
113
|
VCR.use_cassette 'mfa/challenge_factor_generic_valid' do
|
@@ -111,6 +119,7 @@ describe WorkOS::MFA do
|
|
111
119
|
end
|
112
120
|
end
|
113
121
|
end
|
122
|
+
|
114
123
|
describe 'challenge factor with invalid arguments' do
|
115
124
|
context 'challenge with totp mssing authentication_factor_id' do
|
116
125
|
it 'returns argument error' do
|
@@ -123,6 +132,7 @@ describe WorkOS::MFA do
|
|
123
132
|
end
|
124
133
|
end
|
125
134
|
end
|
135
|
+
|
126
136
|
describe 'challenge factor with valid requests' do
|
127
137
|
context 'verify generic otp' do
|
128
138
|
it 'returns a true boolean if the challenge has not been verifed yet' do
|
@@ -135,6 +145,19 @@ describe WorkOS::MFA do
|
|
135
145
|
end
|
136
146
|
end
|
137
147
|
end
|
148
|
+
|
149
|
+
context 'verify generic otp invalid response' do
|
150
|
+
it 'returns a true boolean if the challenge has not been verifed yet' do
|
151
|
+
VCR.use_cassette 'mfa/verify_factor_generic_valid_is_false' do
|
152
|
+
verify_factor = described_class.verify_factor(
|
153
|
+
authentication_challenge_id: 'auth_challenge_01FZ4YVRBMXP5ZM0A7BP4AJ12J',
|
154
|
+
code: '897792',
|
155
|
+
)
|
156
|
+
expect(verify_factor.valid == 'false')
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
138
161
|
context 'verify generic otp' do
|
139
162
|
it 'returns error that the challenge has already been verfied' do
|
140
163
|
VCR.use_cassette 'mfa/verify_factor_generic_invalid' do
|
@@ -146,6 +169,7 @@ describe WorkOS::MFA do
|
|
146
169
|
end.to raise_error(WorkOS::InvalidRequestError)
|
147
170
|
end
|
148
171
|
end
|
172
|
+
|
149
173
|
context 'verify generic otp' do
|
150
174
|
it 'returns error that the challenge has expired' do
|
151
175
|
VCR.use_cassette 'mfa/verify_factor_generic_expired' do
|
@@ -160,6 +184,7 @@ describe WorkOS::MFA do
|
|
160
184
|
end
|
161
185
|
end
|
162
186
|
end
|
187
|
+
|
163
188
|
describe 'verify_factor with invalid argument' do
|
164
189
|
context 'missing code argument' do
|
165
190
|
it 'returns argument error' do
|
@@ -173,8 +198,9 @@ describe WorkOS::MFA do
|
|
173
198
|
)
|
174
199
|
end
|
175
200
|
end
|
201
|
+
|
176
202
|
context 'missing authentication_challenge_id argument' do
|
177
|
-
it '' do
|
203
|
+
it 'returns and error' do
|
178
204
|
expect do
|
179
205
|
described_class.verify_factor(
|
180
206
|
code: '897792',
|
@@ -185,6 +211,7 @@ describe WorkOS::MFA do
|
|
185
211
|
)
|
186
212
|
end
|
187
213
|
end
|
214
|
+
|
188
215
|
context 'missing code and authentication_challenge_id arguments' do
|
189
216
|
it 'returns argument error' do
|
190
217
|
expect do
|
@@ -196,6 +223,7 @@ describe WorkOS::MFA do
|
|
196
223
|
end
|
197
224
|
end
|
198
225
|
end
|
226
|
+
|
199
227
|
describe 'tests returning and deleting a factor' do
|
200
228
|
context 'returns a factor' do
|
201
229
|
it 'uses get_factor to return factor' do
|
@@ -207,6 +235,7 @@ describe WorkOS::MFA do
|
|
207
235
|
end
|
208
236
|
end
|
209
237
|
end
|
238
|
+
|
210
239
|
context 'invalid factor request' do
|
211
240
|
it 'uses get_factor and throws error if id is wrong' do
|
212
241
|
VCR.use_cassette 'mfa/get_factor_invalid' do
|
@@ -218,6 +247,7 @@ describe WorkOS::MFA do
|
|
218
247
|
end
|
219
248
|
end
|
220
249
|
end
|
250
|
+
|
221
251
|
context 'deletes facotr' do
|
222
252
|
it 'uses delete_factor to delete factor' do
|
223
253
|
VCR.use_cassette 'mfa/delete_factor' do
|
@@ -0,0 +1,82 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://api.workos.com/auth/factors/verify
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"authentication_challenge_id":"auth_challenge_01FZ4YVRBMXP5ZM0A7BP4AJ12J","code":"897792"}'
|
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; arm64-darwin21; v2.1.1
|
18
|
+
Authorization:
|
19
|
+
- Bearer <API_KEY>
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 201
|
23
|
+
message: Created
|
24
|
+
headers:
|
25
|
+
Date:
|
26
|
+
- Sun, 27 Mar 2022 05:53:03 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Content-Length:
|
30
|
+
- '317'
|
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
|
+
- 78db6375-0b0a-4492-a913-5e0802a721b7
|
61
|
+
Etag:
|
62
|
+
- W/"13d-MlhrtKBkD4LjqRYZFv0nos58XA8"
|
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=bN92hPz7GN42QtyRg4YR%2BKMTuzd3R241D6A2ktALsB%2F%2FaFwI%2BeJHUMZ9G0oXrDbp%2Binu76aBI%2FC0ICO2Tr0zc8fi9tF1q4XnqyLfgosTjaDE%2BNDcPlRmaduFoDmkc28D4w%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
|
+
- 6f25dd0d0882dee9-SEA
|
75
|
+
Alt-Svc:
|
76
|
+
- h3=":443"; ma=86400, h3-29=":443"; ma=86400
|
77
|
+
body:
|
78
|
+
encoding: UTF-8
|
79
|
+
string: '{"challenge":{"object":"authentication_challenge","id":"auth_challenge_01FZ4YVRBMXP5ZM0A7BP4AJ12J","created_at":"2022-03-27T05:51:24.531Z","updated_at":"2022-03-27T05:51:24.531Z","expires_at":"2022-03-27T06:01:24.532Z","code":"897792","authentication_factor_id":"auth_factor_01FZ4YVH2XFQBJXJ4NQVJSSY8Q"},"valid":false}'
|
80
|
+
http_version:
|
81
|
+
recorded_at: Sun, 27 Mar 2022 05:53:03 GMT
|
82
|
+
recorded_with: VCR 5.0.0
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: workos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- WorkOS
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sorbet-runtime
|
@@ -212,12 +212,14 @@ files:
|
|
212
212
|
- lib/workos/challenge.rb
|
213
213
|
- lib/workos/client.rb
|
214
214
|
- lib/workos/connection.rb
|
215
|
+
- lib/workos/deprecated_hash_wrapper.rb
|
215
216
|
- lib/workos/directory.rb
|
216
217
|
- lib/workos/directory_group.rb
|
217
218
|
- lib/workos/directory_sync.rb
|
218
219
|
- lib/workos/directory_user.rb
|
219
220
|
- lib/workos/errors.rb
|
220
221
|
- lib/workos/factor.rb
|
222
|
+
- lib/workos/hash_provider.rb
|
221
223
|
- lib/workos/mfa.rb
|
222
224
|
- lib/workos/organization.rb
|
223
225
|
- lib/workos/organizations.rb
|
@@ -333,6 +335,7 @@ files:
|
|
333
335
|
- spec/support/fixtures/vcr_cassettes/mfa/verify_factor_generic_expired.yml
|
334
336
|
- spec/support/fixtures/vcr_cassettes/mfa/verify_factor_generic_invalid.yml
|
335
337
|
- spec/support/fixtures/vcr_cassettes/mfa/verify_factor_generic_valid.yml
|
338
|
+
- spec/support/fixtures/vcr_cassettes/mfa/verify_factor_generic_valid_is_false.yml
|
336
339
|
- spec/support/fixtures/vcr_cassettes/organization/create.yml
|
337
340
|
- spec/support/fixtures/vcr_cassettes/organization/create_invalid.yml
|
338
341
|
- spec/support/fixtures/vcr_cassettes/organization/delete.yml
|
@@ -384,7 +387,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
384
387
|
- !ruby/object:Gem::Version
|
385
388
|
version: '0'
|
386
389
|
requirements: []
|
387
|
-
rubygems_version: 3.3.
|
390
|
+
rubygems_version: 3.3.12
|
388
391
|
signing_key:
|
389
392
|
specification_version: 4
|
390
393
|
summary: API client for WorkOS
|
@@ -443,6 +446,7 @@ test_files:
|
|
443
446
|
- spec/support/fixtures/vcr_cassettes/mfa/verify_factor_generic_expired.yml
|
444
447
|
- spec/support/fixtures/vcr_cassettes/mfa/verify_factor_generic_invalid.yml
|
445
448
|
- spec/support/fixtures/vcr_cassettes/mfa/verify_factor_generic_valid.yml
|
449
|
+
- spec/support/fixtures/vcr_cassettes/mfa/verify_factor_generic_valid_is_false.yml
|
446
450
|
- spec/support/fixtures/vcr_cassettes/organization/create.yml
|
447
451
|
- spec/support/fixtures/vcr_cassettes/organization/create_invalid.yml
|
448
452
|
- spec/support/fixtures/vcr_cassettes/organization/delete.yml
|