stytch 6.4.0 → 9.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +13 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +22 -0
- data/DEVELOPMENT.md +5 -2
- data/README.md +52 -3
- data/lib/stytch/b2b_client.rb +18 -3
- data/lib/stytch/b2b_discovery.rb +73 -33
- data/lib/stytch/b2b_magic_links.rb +63 -24
- data/lib/stytch/b2b_oauth.rb +31 -16
- data/lib/stytch/b2b_organizations.rb +788 -51
- data/lib/stytch/b2b_otp.rb +35 -10
- data/lib/stytch/b2b_passwords.rb +141 -44
- data/lib/stytch/b2b_rbac.rb +47 -0
- data/lib/stytch/b2b_recovery_codes.rb +196 -0
- data/lib/stytch/b2b_scim.rb +496 -0
- data/lib/stytch/b2b_sessions.rb +299 -15
- data/lib/stytch/b2b_sso.rb +486 -24
- data/lib/stytch/b2b_totps.rb +255 -0
- data/lib/stytch/client.rb +6 -3
- data/lib/stytch/crypto_wallets.rb +19 -4
- data/lib/stytch/errors.rb +21 -0
- data/lib/stytch/m2m.rb +80 -19
- data/lib/stytch/magic_links.rb +20 -12
- data/lib/stytch/method_options.rb +22 -0
- data/lib/stytch/oauth.rb +10 -4
- data/lib/stytch/otps.rb +27 -17
- data/lib/stytch/passwords.rb +67 -19
- data/lib/stytch/project.rb +26 -0
- data/lib/stytch/rbac_local.rb +58 -0
- data/lib/stytch/request_helper.rb +12 -8
- data/lib/stytch/sessions.rb +131 -31
- data/lib/stytch/totps.rb +9 -5
- data/lib/stytch/users.rb +30 -16
- data/lib/stytch/version.rb +1 -1
- data/lib/stytch/webauthn.rb +126 -24
- data/lib/stytch.rb +1 -0
- data/stytch.gemspec +2 -0
- metadata +42 -6
data/lib/stytch/b2b_otp.rb
CHANGED
@@ -26,7 +26,7 @@ module StytchB2B
|
|
26
26
|
@connection = connection
|
27
27
|
end
|
28
28
|
|
29
|
-
# Send a One-Time Passcode (OTP) to a
|
29
|
+
# Send a One-Time Passcode (OTP) to a's phone number.
|
30
30
|
#
|
31
31
|
# If the Member already has a phone number, the `mfa_phone_number` field is not needed; the endpoint will send an OTP to the number associated with the Member.
|
32
32
|
# If the Member does not have a phone number, the endpoint will send an OTP to the `mfa_phone_number` provided and link the `mfa_phone_number` with the Member.
|
@@ -37,9 +37,15 @@ module StytchB2B
|
|
37
37
|
#
|
38
38
|
# If a Member has a phone number and is enrolled in MFA, then after a successful primary authentication event (e.g. [email magic link](https://stytch.com/docs/b2b/api/authenticate-magic-link) or [SSO](https://stytch.com/docs/b2b/api/sso-authenticate) login is complete), an SMS OTP will automatically be sent to their phone number. In that case, this endpoint should only be used for subsequent authentication events, such as prompting a Member for an OTP again after a period of inactivity.
|
39
39
|
#
|
40
|
+
# Passing an intermediate session token, session token, or session JWT is not required, but if passed must match the Member ID passed.
|
41
|
+
#
|
40
42
|
# ### Cost to send SMS OTP
|
41
43
|
# Before configuring SMS or WhatsApp OTPs, please review how Stytch [bills the costs of international OTPs](https://stytch.com/pricing) and understand how to protect your app against [toll fraud](https://stytch.com/docs/guides/passcodes/toll-fraud/overview).
|
42
44
|
#
|
45
|
+
# Even when international SMS is enabled, we do not support sending SMS to countries on our [Unsupported countries list](https://stytch.com/docs/guides/passcodes/unsupported-countries).
|
46
|
+
#
|
47
|
+
# __Note:__ SMS to phone numbers outside of the US and Canada is disabled by default for customers who did not use SMS prior to October 2023. If you're interested in sending international SMS, please reach out to [support@stytch.com](mailto:support@stytch.com?subject=Enable%20international%20SMS).
|
48
|
+
#
|
43
49
|
# == Parameters:
|
44
50
|
# organization_id::
|
45
51
|
# Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
|
@@ -58,6 +64,15 @@ module StytchB2B
|
|
58
64
|
# Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
|
59
65
|
#
|
60
66
|
# The type of this field is nilable +SendRequestLocale+ (string enum).
|
67
|
+
# intermediate_session_token::
|
68
|
+
# The Intermediate Session Token. This token does not necessarily belong to a specific instance of a Member, but represents a bag of factors that may be converted to a member session. The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms), [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp), or [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete an MFA flow and log in to the Organization. It can also be used with the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) to join a specific Organization that allows the factors represented by the intermediate session token; or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization and Member.
|
69
|
+
# The type of this field is nilable +String+.
|
70
|
+
# session_token::
|
71
|
+
# A secret token for a given Stytch Session.
|
72
|
+
# The type of this field is nilable +String+.
|
73
|
+
# session_jwt::
|
74
|
+
# The JSON Web Token (JWT) for a given Stytch Session.
|
75
|
+
# The type of this field is nilable +String+.
|
61
76
|
#
|
62
77
|
# == Returns:
|
63
78
|
# An object with the following fields:
|
@@ -80,16 +95,23 @@ module StytchB2B
|
|
80
95
|
organization_id:,
|
81
96
|
member_id:,
|
82
97
|
mfa_phone_number: nil,
|
83
|
-
locale: nil
|
98
|
+
locale: nil,
|
99
|
+
intermediate_session_token: nil,
|
100
|
+
session_token: nil,
|
101
|
+
session_jwt: nil
|
84
102
|
)
|
103
|
+
headers = {}
|
85
104
|
request = {
|
86
105
|
organization_id: organization_id,
|
87
106
|
member_id: member_id
|
88
107
|
}
|
89
108
|
request[:mfa_phone_number] = mfa_phone_number unless mfa_phone_number.nil?
|
90
109
|
request[:locale] = locale unless locale.nil?
|
110
|
+
request[:intermediate_session_token] = intermediate_session_token unless intermediate_session_token.nil?
|
111
|
+
request[:session_token] = session_token unless session_token.nil?
|
112
|
+
request[:session_jwt] = session_jwt unless session_jwt.nil?
|
91
113
|
|
92
|
-
post_request('/v1/b2b/otps/sms/send', request)
|
114
|
+
post_request('/v1/b2b/otps/sms/send', request, headers)
|
93
115
|
end
|
94
116
|
|
95
117
|
# SMS OTPs may not be used as a primary authentication mechanism. They can be used to complete an MFA requirement, or they can be used as a step-up factor to be added to an existing session.
|
@@ -103,7 +125,7 @@ module StytchB2B
|
|
103
125
|
# such as [email magic link authenticate](https://stytch.com/docs/b2b/api/authenticate-magic-link),
|
104
126
|
# or upon successful calls to discovery authenticate methods, such as [email magic link discovery authenticate](https://stytch.com/docs/b2b/api/authenticate-discovery-magic-link).
|
105
127
|
#
|
106
|
-
# If the
|
128
|
+
# If the's MFA policy is `REQUIRED_FOR_ALL`, a successful OTP authentication will change the's `mfa_enrolled` status to `true` if it is not already `true`.
|
107
129
|
# If the Organization's MFA policy is `OPTIONAL`, the Member's MFA enrollment can be toggled by passing in a value for the `set_mfa_enrollment` field.
|
108
130
|
# The Member's MFA enrollment can also be toggled through the [Update Member](https://stytch.com/docs/b2b/api/update-member) endpoint.
|
109
131
|
#
|
@@ -120,10 +142,7 @@ module StytchB2B
|
|
120
142
|
# The code to authenticate.
|
121
143
|
# The type of this field is +String+.
|
122
144
|
# intermediate_session_token::
|
123
|
-
# The Intermediate Session Token. This token does not necessarily belong to a specific instance of a Member, but represents a bag of factors that may be converted to a member session.
|
124
|
-
# The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete an MFA flow;
|
125
|
-
# the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) to join a specific Organization that allows the factors represented by the intermediate session token;
|
126
|
-
# or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization and Member.
|
145
|
+
# The Intermediate Session Token. This token does not necessarily belong to a specific instance of a Member, but represents a bag of factors that may be converted to a member session. The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms), [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp), or [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete an MFA flow and log in to the Organization. It can also be used with the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) to join a specific Organization that allows the factors represented by the intermediate session token; or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization and Member.
|
127
146
|
# The type of this field is nilable +String+.
|
128
147
|
# session_token::
|
129
148
|
# A secret token for a given Stytch Session.
|
@@ -157,6 +176,9 @@ module StytchB2B
|
|
157
176
|
# `unenroll` – sets the Member's `mfa_enrolled` boolean to `false`. The Member will no longer be required to complete MFA steps when logging in to the Organization.
|
158
177
|
#
|
159
178
|
# The type of this field is nilable +String+.
|
179
|
+
# set_default_mfa::
|
180
|
+
# (no documentation yet)
|
181
|
+
# The type of this field is nilable +Boolean+.
|
160
182
|
#
|
161
183
|
# == Returns:
|
162
184
|
# An object with the following fields:
|
@@ -193,8 +215,10 @@ module StytchB2B
|
|
193
215
|
session_jwt: nil,
|
194
216
|
session_duration_minutes: nil,
|
195
217
|
session_custom_claims: nil,
|
196
|
-
set_mfa_enrollment: nil
|
218
|
+
set_mfa_enrollment: nil,
|
219
|
+
set_default_mfa: nil
|
197
220
|
)
|
221
|
+
headers = {}
|
198
222
|
request = {
|
199
223
|
organization_id: organization_id,
|
200
224
|
member_id: member_id,
|
@@ -206,8 +230,9 @@ module StytchB2B
|
|
206
230
|
request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
|
207
231
|
request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
|
208
232
|
request[:set_mfa_enrollment] = set_mfa_enrollment unless set_mfa_enrollment.nil?
|
233
|
+
request[:set_default_mfa] = set_default_mfa unless set_default_mfa.nil?
|
209
234
|
|
210
|
-
post_request('/v1/b2b/otps/sms/authenticate', request)
|
235
|
+
post_request('/v1/b2b/otps/sms/authenticate', request, headers)
|
211
236
|
end
|
212
237
|
end
|
213
238
|
end
|
data/lib/stytch/b2b_passwords.rb
CHANGED
@@ -34,7 +34,7 @@ module StytchB2B
|
|
34
34
|
#
|
35
35
|
# == Parameters:
|
36
36
|
# password::
|
37
|
-
# The password to authenticate.
|
37
|
+
# The password to authenticate, reset, or set for the first time. Any UTF8 character is allowed, e.g. spaces, emojis, non-English characers, etc.
|
38
38
|
# The type of this field is +String+.
|
39
39
|
# email_address::
|
40
40
|
# The email address of the Member.
|
@@ -78,16 +78,19 @@ module StytchB2B
|
|
78
78
|
password:,
|
79
79
|
email_address: nil
|
80
80
|
)
|
81
|
+
headers = {}
|
81
82
|
request = {
|
82
83
|
password: password
|
83
84
|
}
|
84
85
|
request[:email_address] = email_address unless email_address.nil?
|
85
86
|
|
86
|
-
post_request('/v1/b2b/passwords/strength_check', request)
|
87
|
+
post_request('/v1/b2b/passwords/strength_check', request, headers)
|
87
88
|
end
|
88
89
|
|
89
90
|
# Adds an existing password to a member's email that doesn't have a password yet. We support migrating members from passwords stored with bcrypt, scrypt, argon2, MD-5, SHA-1, and PBKDF2. This endpoint has a rate limit of 100 requests per second.
|
90
91
|
#
|
92
|
+
# The member's email will be marked as verified when you use this endpoint.
|
93
|
+
#
|
91
94
|
# == Parameters:
|
92
95
|
# email_address::
|
93
96
|
# The email address of the Member.
|
@@ -96,7 +99,7 @@ module StytchB2B
|
|
96
99
|
# The password hash. For a Scrypt or PBKDF2 hash, the hash needs to be a base64 encoded string.
|
97
100
|
# The type of this field is +String+.
|
98
101
|
# hash_type::
|
99
|
-
# The password hash used. Currently `bcrypt`, `scrypt`, `
|
102
|
+
# The password hash used. Currently `bcrypt`, `scrypt`, `argon_2i`, `argon2_id`, `md_5`, `sha_1`, and `pbkdf_2` are supported.
|
100
103
|
# The type of this field is +MigrateRequestHashType+ (string enum).
|
101
104
|
# organization_id::
|
102
105
|
# Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
|
@@ -127,6 +130,21 @@ module StytchB2B
|
|
127
130
|
# frontend SDK, and should not be used to store critical information. See the [Metadata resource](https://stytch.com/docs/b2b/api/metadata)
|
128
131
|
# for complete field behavior details.
|
129
132
|
# The type of this field is nilable +object+.
|
133
|
+
# roles::
|
134
|
+
# Roles to explicitly assign to this Member.
|
135
|
+
# Will completely replace any existing explicitly assigned roles. See the
|
136
|
+
# [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment) for more information about role assignment.
|
137
|
+
#
|
138
|
+
# If a Role is removed from a Member, and the Member is also implicitly assigned this Role from an SSO connection
|
139
|
+
# or an SSO group, we will by default revoke any existing sessions for the Member that contain any SSO
|
140
|
+
# authentication factors with the affected connection ID. You can preserve these sessions by passing in the
|
141
|
+
# `preserve_existing_sessions` parameter with a value of `true`.
|
142
|
+
# The type of this field is nilable list of +String+.
|
143
|
+
# preserve_existing_sessions::
|
144
|
+
# Whether to preserve existing sessions when explicit Roles that are revoked are also implicitly assigned
|
145
|
+
# by SSO connection or SSO group. Defaults to `false` - that is, existing Member Sessions that contain SSO
|
146
|
+
# authentication factors with the affected SSO connection IDs will be revoked.
|
147
|
+
# The type of this field is nilable +Boolean+.
|
130
148
|
#
|
131
149
|
# == Returns:
|
132
150
|
# An object with the following fields:
|
@@ -160,8 +178,11 @@ module StytchB2B
|
|
160
178
|
pbkdf_2_config: nil,
|
161
179
|
name: nil,
|
162
180
|
trusted_metadata: nil,
|
163
|
-
untrusted_metadata: nil
|
181
|
+
untrusted_metadata: nil,
|
182
|
+
roles: nil,
|
183
|
+
preserve_existing_sessions: nil
|
164
184
|
)
|
185
|
+
headers = {}
|
165
186
|
request = {
|
166
187
|
email_address: email_address,
|
167
188
|
hash: hash,
|
@@ -176,18 +197,17 @@ module StytchB2B
|
|
176
197
|
request[:name] = name unless name.nil?
|
177
198
|
request[:trusted_metadata] = trusted_metadata unless trusted_metadata.nil?
|
178
199
|
request[:untrusted_metadata] = untrusted_metadata unless untrusted_metadata.nil?
|
200
|
+
request[:roles] = roles unless roles.nil?
|
201
|
+
request[:preserve_existing_sessions] = preserve_existing_sessions unless preserve_existing_sessions.nil?
|
179
202
|
|
180
|
-
post_request('/v1/b2b/passwords/migrate', request)
|
203
|
+
post_request('/v1/b2b/passwords/migrate', request, headers)
|
181
204
|
end
|
182
205
|
|
183
|
-
# Authenticate a member with their email address and password. This endpoint verifies that the member has a password currently set, and that the entered password is correct.
|
184
|
-
#
|
185
|
-
#
|
186
|
-
# * A member that has previously authenticated with email/password uses a passwordless authentication method tied to the same email address (e.g. Magic Links) for the first time. Any subsequent email/password authentication attempt will result in this error.
|
187
|
-
# * We force a password reset in this instance in order to safely deduplicate the account by email address, without introducing the risk of a pre-hijack account takeover attack.
|
188
|
-
# * Imagine a bad actor creates many accounts using passwords and the known email addresses of their victims. If a victim comes to the site and logs in for the first time with an email-based passwordless authentication method then both the victim and the bad actor have credentials to access to the same account. To prevent this, any further email/password login attempts first require a password reset which can only be accomplished by someone with access to the underlying email address.
|
206
|
+
# Authenticate a member with their email address and password. This endpoint verifies that the member has a password currently set, and that the entered password is correct.
|
207
|
+
#
|
208
|
+
# If you have breach detection during authentication enabled in your [password strength policy](https://stytch.com/docs/b2b/guides/passwords/strength-policies) and the member's credentials have appeared in the HaveIBeenPwned dataset, this endpoint will return a `member_reset_password` error even if the member enters a correct password. We force a password reset in this case to ensure that the member is the legitimate owner of the email address and not a malicious actor abusing the compromised credentials.
|
189
209
|
#
|
190
|
-
# If the
|
210
|
+
# If the is required to complete MFA to log in to the, the returned value of `member_authenticated` will be `false`, and an `intermediate_session_token` will be returned.
|
191
211
|
# The `intermediate_session_token` can be passed into the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete the MFA step and acquire a full member session.
|
192
212
|
# The `session_duration_minutes` and `session_custom_claims` parameters will be ignored.
|
193
213
|
#
|
@@ -201,7 +221,7 @@ module StytchB2B
|
|
201
221
|
# The email address of the Member.
|
202
222
|
# The type of this field is +String+.
|
203
223
|
# password::
|
204
|
-
# The password to authenticate.
|
224
|
+
# The password to authenticate, reset, or set for the first time. Any UTF8 character is allowed, e.g. spaces, emojis, non-English characers, etc.
|
205
225
|
# The type of this field is +String+.
|
206
226
|
# session_token::
|
207
227
|
# A secret token for a given Stytch Session.
|
@@ -228,7 +248,7 @@ module StytchB2B
|
|
228
248
|
# Total custom claims size cannot exceed four kilobytes.
|
229
249
|
# The type of this field is nilable +object+.
|
230
250
|
# locale::
|
231
|
-
# If the
|
251
|
+
# If the needs to complete an MFA step, and the Member has a phone number, this endpoint will pre-emptively send a one-time passcode (OTP) to the Member's phone number. The locale argument will be used to determine which language to use when sending the passcode.
|
232
252
|
#
|
233
253
|
# Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
|
234
254
|
#
|
@@ -237,6 +257,9 @@ module StytchB2B
|
|
237
257
|
# Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
|
238
258
|
#
|
239
259
|
# The type of this field is nilable +AuthenticateRequestLocale+ (string enum).
|
260
|
+
# intermediate_session_token::
|
261
|
+
# Adds this primary authentication factor to the intermediate session token. If the resulting set of factors satisfies the organization's primary authentication requirements and MFA requirements, the intermediate session token will be consumed and converted to a member session. If not, the same intermediate session token will be returned.
|
262
|
+
# The type of this field is nilable +String+.
|
240
263
|
#
|
241
264
|
# == Returns:
|
242
265
|
# An object with the following fields:
|
@@ -262,9 +285,7 @@ module StytchB2B
|
|
262
285
|
# The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
|
263
286
|
# The type of this field is +Organization+ (+object+).
|
264
287
|
# intermediate_session_token::
|
265
|
-
# The returned Intermediate Session Token contains a password factor associated with the Member.
|
266
|
-
# The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete the MFA flow and log in to the Organization.
|
267
|
-
# Password factors are not transferable between Organizations, so the intermediate session token is not valid for use with discovery endpoints.
|
288
|
+
# The returned Intermediate Session Token contains a password factor associated with the Member. If this value is non-empty, the member must complete an MFA step to finish logging in to the Organization. The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms), [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp), or [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete an MFA flow and log in to the Organization. Password factors are not transferable between Organizations, so the intermediate session token is not valid for use with discovery endpoints.
|
268
289
|
# The type of this field is +String+.
|
269
290
|
# member_authenticated::
|
270
291
|
# Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization.
|
@@ -286,8 +307,10 @@ module StytchB2B
|
|
286
307
|
session_duration_minutes: nil,
|
287
308
|
session_jwt: nil,
|
288
309
|
session_custom_claims: nil,
|
289
|
-
locale: nil
|
310
|
+
locale: nil,
|
311
|
+
intermediate_session_token: nil
|
290
312
|
)
|
313
|
+
headers = {}
|
291
314
|
request = {
|
292
315
|
organization_id: organization_id,
|
293
316
|
email_address: email_address,
|
@@ -298,8 +321,9 @@ module StytchB2B
|
|
298
321
|
request[:session_jwt] = session_jwt unless session_jwt.nil?
|
299
322
|
request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
|
300
323
|
request[:locale] = locale unless locale.nil?
|
324
|
+
request[:intermediate_session_token] = intermediate_session_token unless intermediate_session_token.nil?
|
301
325
|
|
302
|
-
post_request('/v1/b2b/passwords/authenticate', request)
|
326
|
+
post_request('/v1/b2b/passwords/authenticate', request, headers)
|
303
327
|
end
|
304
328
|
|
305
329
|
class Email
|
@@ -364,6 +388,9 @@ module StytchB2B
|
|
364
388
|
# member_email_id::
|
365
389
|
# Globally unique UUID that identifies a member's email
|
366
390
|
# The type of this field is +String+.
|
391
|
+
# member::
|
392
|
+
# The [Member object](https://stytch.com/docs/b2b/api/member-object)
|
393
|
+
# The type of this field is +Member+ (+object+).
|
367
394
|
# status_code::
|
368
395
|
# The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
|
369
396
|
# The type of this field is +Integer+.
|
@@ -377,24 +404,22 @@ module StytchB2B
|
|
377
404
|
locale: nil,
|
378
405
|
reset_password_template_id: nil
|
379
406
|
)
|
407
|
+
headers = {}
|
380
408
|
request = {
|
381
409
|
organization_id: organization_id,
|
382
410
|
email_address: email_address
|
383
411
|
}
|
384
412
|
request[:reset_password_redirect_url] = reset_password_redirect_url unless reset_password_redirect_url.nil?
|
385
|
-
unless reset_password_expiration_minutes.nil?
|
386
|
-
request[:reset_password_expiration_minutes] =
|
387
|
-
reset_password_expiration_minutes
|
388
|
-
end
|
413
|
+
request[:reset_password_expiration_minutes] = reset_password_expiration_minutes unless reset_password_expiration_minutes.nil?
|
389
414
|
request[:code_challenge] = code_challenge unless code_challenge.nil?
|
390
415
|
request[:login_redirect_url] = login_redirect_url unless login_redirect_url.nil?
|
391
416
|
request[:locale] = locale unless locale.nil?
|
392
417
|
request[:reset_password_template_id] = reset_password_template_id unless reset_password_template_id.nil?
|
393
418
|
|
394
|
-
post_request('/v1/b2b/passwords/email/reset/start', request)
|
419
|
+
post_request('/v1/b2b/passwords/email/reset/start', request, headers)
|
395
420
|
end
|
396
421
|
|
397
|
-
# Reset the
|
422
|
+
# Reset the's password and authenticate them. This endpoint checks that the password reset token is valid, hasn’t expired, or already been used.
|
398
423
|
#
|
399
424
|
# The provided password needs to meet our password strength requirements, which can be checked in advance with the password strength endpoint. If the token and password are accepted, the password is securely stored for future authentication and the user is authenticated.
|
400
425
|
#
|
@@ -404,12 +429,14 @@ module StytchB2B
|
|
404
429
|
#
|
405
430
|
# If a valid `session_token` or `session_jwt` is passed in, the Member will not be required to complete an MFA step.
|
406
431
|
#
|
432
|
+
# Note that a successful password reset by email will revoke all active sessions for the `member_id`.
|
433
|
+
#
|
407
434
|
# == Parameters:
|
408
435
|
# password_reset_token::
|
409
436
|
# The password reset token to authenticate.
|
410
437
|
# The type of this field is +String+.
|
411
438
|
# password::
|
412
|
-
# The password to reset.
|
439
|
+
# The password to authenticate, reset, or set for the first time. Any UTF8 character is allowed, e.g. spaces, emojis, non-English characers, etc.
|
413
440
|
# The type of this field is +String+.
|
414
441
|
# session_token::
|
415
442
|
# Reuse an existing session instead of creating a new one. If you provide a `session_token`, Stytch will update the session.
|
@@ -443,7 +470,7 @@ module StytchB2B
|
|
443
470
|
# Total custom claims size cannot exceed four kilobytes.
|
444
471
|
# The type of this field is nilable +object+.
|
445
472
|
# locale::
|
446
|
-
# If the
|
473
|
+
# If the needs to complete an MFA step, and the Member has a phone number, this endpoint will pre-emptively send a one-time passcode (OTP) to the Member's phone number. The locale argument will be used to determine which language to use when sending the passcode.
|
447
474
|
#
|
448
475
|
# Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
|
449
476
|
#
|
@@ -452,6 +479,9 @@ module StytchB2B
|
|
452
479
|
# Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
|
453
480
|
#
|
454
481
|
# The type of this field is nilable +ResetRequestLocale+ (string enum).
|
482
|
+
# intermediate_session_token::
|
483
|
+
# Adds this primary authentication factor to the intermediate session token. If the resulting set of factors satisfies the organization's primary authentication requirements and MFA requirements, the intermediate session token will be consumed and converted to a member session. If not, the same intermediate session token will be returned.
|
484
|
+
# The type of this field is nilable +String+.
|
455
485
|
#
|
456
486
|
# == Returns:
|
457
487
|
# An object with the following fields:
|
@@ -480,9 +510,7 @@ module StytchB2B
|
|
480
510
|
# The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
|
481
511
|
# The type of this field is +Organization+ (+object+).
|
482
512
|
# intermediate_session_token::
|
483
|
-
# The returned Intermediate Session Token contains a password factor associated with the Member.
|
484
|
-
# The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete the MFA flow and log in to the Organization.
|
485
|
-
# Password factors are not transferable between Organizations, so the intermediate session token is not valid for use with discovery endpoints.
|
513
|
+
# The returned Intermediate Session Token contains a password factor associated with the Member. If this value is non-empty, the member must complete an MFA step to finish logging in to the Organization. The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms), [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp), or [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete an MFA flow and log in to the Organization. Password factors are not transferable between Organizations, so the intermediate session token is not valid for use with discovery endpoints.
|
486
514
|
# The type of this field is +String+.
|
487
515
|
# member_authenticated::
|
488
516
|
# Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization.
|
@@ -504,8 +532,10 @@ module StytchB2B
|
|
504
532
|
session_jwt: nil,
|
505
533
|
code_verifier: nil,
|
506
534
|
session_custom_claims: nil,
|
507
|
-
locale: nil
|
535
|
+
locale: nil,
|
536
|
+
intermediate_session_token: nil
|
508
537
|
)
|
538
|
+
headers = {}
|
509
539
|
request = {
|
510
540
|
password_reset_token: password_reset_token,
|
511
541
|
password: password
|
@@ -516,8 +546,24 @@ module StytchB2B
|
|
516
546
|
request[:code_verifier] = code_verifier unless code_verifier.nil?
|
517
547
|
request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
|
518
548
|
request[:locale] = locale unless locale.nil?
|
549
|
+
request[:intermediate_session_token] = intermediate_session_token unless intermediate_session_token.nil?
|
519
550
|
|
520
|
-
post_request('/v1/b2b/passwords/email/reset', request)
|
551
|
+
post_request('/v1/b2b/passwords/email/reset', request, headers)
|
552
|
+
end
|
553
|
+
|
554
|
+
def delete(
|
555
|
+
email_address:,
|
556
|
+
organization_id: nil,
|
557
|
+
member_id: nil
|
558
|
+
)
|
559
|
+
headers = {}
|
560
|
+
request = {
|
561
|
+
email_address: email_address
|
562
|
+
}
|
563
|
+
request[:organization_id] = organization_id unless organization_id.nil?
|
564
|
+
request[:member_id] = member_id unless member_id.nil?
|
565
|
+
|
566
|
+
post_request('/v1/b2b/passwords/email/delete', request, headers)
|
521
567
|
end
|
522
568
|
end
|
523
569
|
|
@@ -528,14 +574,16 @@ module StytchB2B
|
|
528
574
|
@connection = connection
|
529
575
|
end
|
530
576
|
|
531
|
-
# Reset the
|
577
|
+
# Reset the's password using their existing session. The endpoint will error if the session does not contain an authentication factor that has been issued within the last 5 minutes. Either `session_token` or `session_jwt` should be provided.
|
578
|
+
#
|
579
|
+
# Note that a successful password reset via an existing session will revoke all active sessions for the `member_id`, except for the one used during the reset flow.
|
532
580
|
#
|
533
581
|
# == Parameters:
|
534
582
|
# organization_id::
|
535
583
|
# Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
|
536
584
|
# The type of this field is +String+.
|
537
585
|
# password::
|
538
|
-
# The password to authenticate.
|
586
|
+
# The password to authenticate, reset, or set for the first time. Any UTF8 character is allowed, e.g. spaces, emojis, non-English characers, etc.
|
539
587
|
# The type of this field is +String+.
|
540
588
|
# session_token::
|
541
589
|
# A secret token for a given Stytch Session.
|
@@ -543,6 +591,32 @@ module StytchB2B
|
|
543
591
|
# session_jwt::
|
544
592
|
# The JSON Web Token (JWT) for a given Stytch Session.
|
545
593
|
# The type of this field is nilable +String+.
|
594
|
+
# session_duration_minutes::
|
595
|
+
# Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
|
596
|
+
# returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of
|
597
|
+
# five minutes regardless of the underlying session duration, and will need to be refreshed over time.
|
598
|
+
#
|
599
|
+
# This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).
|
600
|
+
#
|
601
|
+
# If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes.
|
602
|
+
#
|
603
|
+
# If the `session_duration_minutes` parameter is not specified, a Stytch session will be created with a 60 minute duration. If you don't want
|
604
|
+
# to use the Stytch session product, you can ignore the session fields in the response.
|
605
|
+
# The type of this field is nilable +Integer+.
|
606
|
+
# session_custom_claims::
|
607
|
+
# Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in
|
608
|
+
# `session_duration_minutes`. Claims will be included on the Session object and in the JWT. To update a key in an existing Session, supply a new value. To
|
609
|
+
# delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored.
|
610
|
+
# Total custom claims size cannot exceed four kilobytes.
|
611
|
+
# The type of this field is nilable +object+.
|
612
|
+
# locale::
|
613
|
+
# Used to determine which language to use when sending the user this delivery method. Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
|
614
|
+
#
|
615
|
+
# Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English.
|
616
|
+
#
|
617
|
+
# Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
|
618
|
+
#
|
619
|
+
# The type of this field is nilable +ResetRequestLocale+ (string enum).
|
546
620
|
#
|
547
621
|
# == Returns:
|
548
622
|
# An object with the following fields:
|
@@ -558,26 +632,48 @@ module StytchB2B
|
|
558
632
|
# organization::
|
559
633
|
# The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
|
560
634
|
# The type of this field is +Organization+ (+object+).
|
635
|
+
# session_token::
|
636
|
+
# A secret token for a given Stytch Session.
|
637
|
+
# The type of this field is +String+.
|
638
|
+
# session_jwt::
|
639
|
+
# The JSON Web Token (JWT) for a given Stytch Session.
|
640
|
+
# The type of this field is +String+.
|
641
|
+
# intermediate_session_token::
|
642
|
+
# The Intermediate Session Token. This token does not necessarily belong to a specific instance of a Member, but represents a bag of factors that may be converted to a member session. The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms), [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp), or [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete an MFA flow and log in to the Organization. It can also be used with the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) to join a specific Organization that allows the factors represented by the intermediate session token; or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization and Member.
|
643
|
+
# The type of this field is +String+.
|
644
|
+
# member_authenticated::
|
645
|
+
# Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization.
|
646
|
+
# The type of this field is +Boolean+.
|
561
647
|
# status_code::
|
562
648
|
# The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
|
563
649
|
# The type of this field is +Integer+.
|
564
650
|
# member_session::
|
565
651
|
# The [Session object](https://stytch.com/docs/b2b/api/session-object).
|
566
652
|
# The type of this field is nilable +MemberSession+ (+object+).
|
653
|
+
# mfa_required::
|
654
|
+
# Information about the MFA requirements of the Organization and the Member's options for fulfilling MFA.
|
655
|
+
# The type of this field is nilable +MfaRequired+ (+object+).
|
567
656
|
def reset(
|
568
657
|
organization_id:,
|
569
658
|
password:,
|
570
659
|
session_token: nil,
|
571
|
-
session_jwt: nil
|
660
|
+
session_jwt: nil,
|
661
|
+
session_duration_minutes: nil,
|
662
|
+
session_custom_claims: nil,
|
663
|
+
locale: nil
|
572
664
|
)
|
665
|
+
headers = {}
|
573
666
|
request = {
|
574
667
|
organization_id: organization_id,
|
575
668
|
password: password
|
576
669
|
}
|
577
670
|
request[:session_token] = session_token unless session_token.nil?
|
578
671
|
request[:session_jwt] = session_jwt unless session_jwt.nil?
|
672
|
+
request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
|
673
|
+
request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
|
674
|
+
request[:locale] = locale unless locale.nil?
|
579
675
|
|
580
|
-
post_request('/v1/b2b/passwords/session/reset', request)
|
676
|
+
post_request('/v1/b2b/passwords/session/reset', request, headers)
|
581
677
|
end
|
582
678
|
end
|
583
679
|
|
@@ -588,7 +684,7 @@ module StytchB2B
|
|
588
684
|
@connection = connection
|
589
685
|
end
|
590
686
|
|
591
|
-
# Reset the
|
687
|
+
# Reset the’s password using their existing password.
|
592
688
|
#
|
593
689
|
# This endpoint adapts to your Project's password strength configuration.
|
594
690
|
# If you're using [zxcvbn](https://stytch.com/docs/guides/passwords/strength-policy), the default, your passwords are considered valid
|
@@ -602,15 +698,17 @@ module StytchB2B
|
|
602
698
|
#
|
603
699
|
# If a valid `session_token` or `session_jwt` is passed in, the Member will not be required to complete an MFA step.
|
604
700
|
#
|
701
|
+
# Note that a successful password reset via an existing password will revoke all active sessions for the `member_id`.
|
702
|
+
#
|
605
703
|
# == Parameters:
|
606
704
|
# email_address::
|
607
705
|
# The email address of the Member.
|
608
706
|
# The type of this field is +String+.
|
609
707
|
# existing_password::
|
610
|
-
# The
|
708
|
+
# The Member's current password that they supplied.
|
611
709
|
# The type of this field is +String+.
|
612
710
|
# new_password::
|
613
|
-
# The
|
711
|
+
# The Member's elected new password.
|
614
712
|
# The type of this field is +String+.
|
615
713
|
# organization_id::
|
616
714
|
# Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
|
@@ -640,7 +738,7 @@ module StytchB2B
|
|
640
738
|
# Total custom claims size cannot exceed four kilobytes.
|
641
739
|
# The type of this field is nilable +object+.
|
642
740
|
# locale::
|
643
|
-
# If the
|
741
|
+
# If the needs to complete an MFA step, and the Member has a phone number, this endpoint will pre-emptively send a one-time passcode (OTP) to the Member's phone number. The locale argument will be used to determine which language to use when sending the passcode.
|
644
742
|
#
|
645
743
|
# Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
|
646
744
|
#
|
@@ -671,9 +769,7 @@ module StytchB2B
|
|
671
769
|
# The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
|
672
770
|
# The type of this field is +Organization+ (+object+).
|
673
771
|
# intermediate_session_token::
|
674
|
-
# The returned Intermediate Session Token contains a password factor associated with the Member.
|
675
|
-
# The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete the MFA flow and log in to the Organization.
|
676
|
-
# Password factors are not transferable between Organizations, so the intermediate session token is not valid for use with discovery endpoints.
|
772
|
+
# The returned Intermediate Session Token contains a password factor associated with the Member. If this value is non-empty, the member must complete an MFA step to finish logging in to the Organization. The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms), [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp), or [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete an MFA flow and log in to the Organization. Password factors are not transferable between Organizations, so the intermediate session token is not valid for use with discovery endpoints.
|
677
773
|
# The type of this field is +String+.
|
678
774
|
# member_authenticated::
|
679
775
|
# Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization.
|
@@ -698,6 +794,7 @@ module StytchB2B
|
|
698
794
|
session_custom_claims: nil,
|
699
795
|
locale: nil
|
700
796
|
)
|
797
|
+
headers = {}
|
701
798
|
request = {
|
702
799
|
email_address: email_address,
|
703
800
|
existing_password: existing_password,
|
@@ -710,7 +807,7 @@ module StytchB2B
|
|
710
807
|
request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
|
711
808
|
request[:locale] = locale unless locale.nil?
|
712
809
|
|
713
|
-
post_request('/v1/b2b/passwords/existing_password/reset', request)
|
810
|
+
post_request('/v1/b2b/passwords/existing_password/reset', request, headers)
|
714
811
|
end
|
715
812
|
end
|
716
813
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# !!!
|
4
|
+
# WARNING: This file is autogenerated
|
5
|
+
# Only modify code within MANUAL() sections
|
6
|
+
# or your changes may be overwritten later!
|
7
|
+
# !!!
|
8
|
+
|
9
|
+
require_relative 'request_helper'
|
10
|
+
|
11
|
+
module StytchB2B
|
12
|
+
class RBAC
|
13
|
+
include Stytch::RequestHelper
|
14
|
+
|
15
|
+
def initialize(connection)
|
16
|
+
@connection = connection
|
17
|
+
end
|
18
|
+
|
19
|
+
# Get the active RBAC Policy for your current Stytch Project. An RBAC Policy is the canonical document that stores all defined Resources and Roles within your RBAC permissioning model.
|
20
|
+
#
|
21
|
+
# When using the backend SDKs, the RBAC Policy will be cached to allow for local evaluations, eliminating the need for an extra request to Stytch. The policy will be refreshed if an authorization check is requested and the RBAC policy was last updated more than 5 minutes ago.
|
22
|
+
#
|
23
|
+
# Resources and Roles can be created and managed within the [Dashboard](/dashboard/rbac). Additionally, [Role assignment](https://stytch.com/docs/b2b/guides/rbac/role-assignment) can be programmatically managed through certain Stytch API endpoints.
|
24
|
+
#
|
25
|
+
# Check out the [RBAC overview](https://stytch.com/docs/b2b/guides/rbac/overview) to learn more about Stytch's RBAC permissioning model.
|
26
|
+
#
|
27
|
+
# == Parameters:
|
28
|
+
#
|
29
|
+
# == Returns:
|
30
|
+
# An object with the following fields:
|
31
|
+
# request_id::
|
32
|
+
# Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
|
33
|
+
# The type of this field is +String+.
|
34
|
+
# status_code::
|
35
|
+
# The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
|
36
|
+
# The type of this field is +Integer+.
|
37
|
+
# policy::
|
38
|
+
# The RBAC Policy document that contains all defined Roles and Resources – which are managed in the [Dashboard](/dashboard/rbac). Read more about these entities and how they work in our [RBAC overview](https://stytch.com/docs/b2b/guides/rbac/overview).
|
39
|
+
# The type of this field is nilable +Policy+ (+object+).
|
40
|
+
def policy
|
41
|
+
headers = {}
|
42
|
+
query_params = {}
|
43
|
+
request = request_with_query_params('/v1/b2b/rbac/policy', query_params)
|
44
|
+
get_request(request, headers)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|