Skip to content

Commit cbdd305

Browse files
gaultiervinckr
andauthored
docs: expand docs for SMS recovery (#2261)
* add section in account page * expand recovery docs * mention limit of 10 * links * expand recovery docs * expand recovery docs * make format * Update docs/identities/get-started/account-recovery.mdx Co-authored-by: Vincent <[email protected]> * Update docs/identities/get-started/account-recovery.mdx Co-authored-by: Vincent <[email protected]> * Update docs/identities/get-started/account-recovery.mdx Co-authored-by: Vincent <[email protected]> * Update docs/identities/get-started/account-recovery.mdx Co-authored-by: Vincent <[email protected]> * make format * Update docs/identities/get-started/account-recovery.mdx Co-authored-by: Vincent <[email protected]> * Update docs/identities/get-started/account-recovery.mdx Co-authored-by: Vincent <[email protected]> * Update docs/identities/get-started/account-recovery.mdx Co-authored-by: Vincent <[email protected]> * Update docs/kratos/self-service/flows/account-recovery-password-reset.mdx Co-authored-by: Vincent <[email protected]> * Update docs/kratos/self-service/flows/account-recovery-password-reset.mdx Co-authored-by: Vincent <[email protected]> * Update docs/kratos/self-service/flows/account-recovery-password-reset.mdx Co-authored-by: Vincent <[email protected]> * Update docs/kratos/self-service/flows/account-recovery-password-reset.mdx Co-authored-by: Vincent <[email protected]> * Update docs/kratos/self-service/flows/account-recovery-password-reset.mdx Co-authored-by: Vincent <[email protected]> * merge Admin/Dev sections & mention ignored fields * format * fix ignored fields * make format * fix * s/elements/Account Experience/ * fix link & add API link * Update docs/identities/get-started/account-recovery.mdx Co-authored-by: Vincent <[email protected]> * Update docs/kratos/self-service/flows/account-recovery-password-reset.mdx Co-authored-by: Vincent <[email protected]> * s/a SMS/an SMS/ * address review comments * address review comments * address review comments * address review comments * address review comments * revamp section about api changes * wording * make format --------- Co-authored-by: Vincent <[email protected]>
1 parent bff7e18 commit cbdd305

File tree

2 files changed

+153
-15
lines changed

2 files changed

+153
-15
lines changed

docs/identities/get-started/account-recovery.mdx

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,72 @@ configure account recovery in your Ory project.
4242
</BrowserWindow>
4343
```
4444

45-
### Enable SMS account recovery
45+
### Enable users to choose email or SMS recovery method
4646

47-
Enable the feature flag `choose_recovery_address` to be able to send a recovery code via SMS.
47+
This feature is enabled via a project-level feature flag, which is `on` by default for new projects in Ory Network.
48+
49+
This feature is only available for the one-time password recovery option, and not when using magic links for recovery.
50+
51+
A [SMS HTTP gateway](../../kratos/emails-sms/10_sending-sms.mdx) must be configured to deliver SMS messages.
52+
53+
#### As a user
54+
55+
For users that use only email as their identifier (a phone number was not provided), the recovery process remains the same.
56+
57+
To receive a recovery code via SMS, the user's phone number must be registered as a recovery address.
58+
59+
If the user has multiple recovery addresses registered, they will be prompted to choose one from a masked list during the recovery
60+
process.
61+
62+
To confirm ownership, the user may be asked to enter the complete address after selecting it. This verification step is skipped if
63+
they already entered that same address to begin the recovery process.
64+
65+
#### As an administrator
66+
67+
Enable the `choose_recovery_address` feature flag to send a SMS containing a recovery code.
68+
69+
It is safe to toggle this feature flag. Changes only take effect when a new recovery flow is initiated; existing flows are
70+
unaffected.
71+
72+
##### When using EOL/Open-source
73+
74+
Edit the configuration of Kratos (Ory Identities) to set the `choose_recovery_address` feature flag to `true`:
75+
76+
```diff
77+
feature_flags:
78+
use_continue_with_transitions: true
79+
+ choose_recovery_address: true
80+
```
81+
82+
##### When using Ory Network
4883

4984
1. Log in to your [Ory Console](https://console.ory.sh/)
5085
2. Select your workspace and project
5186
3. Navigate to <ConsoleLink route="project.settings.advanced" />
5287
4. Toggle "Receive a recovery code via SMS" to 'on'
5388
5. Click **Save**
5489

90+
##### As a developer
91+
92+
When integrating with the API directly, your applications must send and receive these fields. Refer to the
93+
[API documentation](../../reference/api#tag/frontend/operation/updateRecoveryFlow) for more details.
94+
95+
When using the built-in Account Experience UI, there is nothing special to do. Otherwise, you need to do some changes.
96+
97+
New fields have been added to the payload when getting and updating the recovery flow that are exclusively used when this feature
98+
flag is enabled:
99+
100+
- `recovery_address`
101+
- `recovery_select_address`
102+
- `recovery_confirm_address`
103+
- `screen`
104+
105+
And these fields will have no effect anymore (they can be present in the payload, but will be ignored):
106+
107+
- `email`
108+
109+
A maximum of 10 recovery addresses are shown to a user during the recovery flow.
110+
55111
### Recovery strategy
56112

57113
You can choose between the following recovery strategies:
@@ -188,5 +244,5 @@ If the address is malformed, or well-formed but not registered as a recovery add
188244
> If this was you, check if you signed up using a different address.
189245
>
190246
> If this was not you, please ignore this email.
191-
- If the address is a phone number (meaning a SMS would be sent), or if the configuration value
247+
- If the address is a phone number (meaning an SMS would be sent), or if the configuration value
192248
`selfservice.flows.recovery.notify_unknown_recipients` is disabled, nothing will be sent.

docs/kratos/self-service/flows/account-recovery-password-reset.mdx

Lines changed: 94 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,24 @@ In the Ory Console go to <ConsoleLink route="project.mfa" />
160160
### Account recovery address
161161

162162
To start account recovery, Ory Identities must know which address to send the recovery message to. Usually this is the email
163-
address the user provides when registering their account. Other fields inside the `traits` section are supported as well.
163+
address the user provides when registering their account. Other fields inside the `traits` section are supported as well such as
164+
phone number to receive the code via an SMS.
165+
166+
If a user has multiple recovery addresses and the `choose_recovery_address` feature flag is
167+
[enabled](../../../identities/get-started/account-recovery.mdx#enable-the-feature-flag-choose_recovery_address-unlocks-sending-a-recovery-code-via-sms),
168+
the process is as follows:
169+
170+
1. The user enters any of their registered addresses to begin the recovery flow.
171+
1. A masked list of their recovery addresses is displayed. Up to 10 addresses are shown.
172+
1. After selecting an address, the user must enter it in full. This step verifies ownership and helps prevent information leaks.
173+
1. The recovery message is sent to the confirmed address via email or SMS.
174+
175+
A [SMS HTTP gateway](../../emails-sms/10_sending-sms.mdx) must be configured to deliver SMS messages.
164176

165177
:::info
166178

167-
If the email address used for recovery is the same as the email used for verification and the account isn't activated when the
168-
recovery flow is started, completing the recovery flow also verifies the user's email address.
179+
If the address used for recovery is the same as the address used for verification and the account isn't activated when the
180+
recovery flow is started, completing the recovery flow also verifies the user's address.
169181

170182
Read [this document](./verify-email-account-activation.mdx) to learn about the account verification flow.
171183

@@ -204,14 +216,79 @@ To specify a trait of the identity to be used for recovery, use the following id
204216
}
205217
```
206218

219+
Example to allow recovery via an email or an SMS:
220+
221+
```json
222+
{
223+
"$id": "https://example.com/registration.schema.json",
224+
"$schema": "http://json-schema.org/draft-07/schema#",
225+
"title": "Person",
226+
"type": "object",
227+
"properties": {
228+
"traits": {
229+
"type": "object",
230+
"properties": {
231+
"email": {
232+
"title": "Email",
233+
"type": "string",
234+
"format": "email",
235+
"ory.sh/kratos": {
236+
"credentials": {
237+
"password": {
238+
"identifier": true
239+
},
240+
"code": {
241+
"identifier": true,
242+
"via": "email"
243+
}
244+
},
245+
"recovery": {
246+
"via": "email"
247+
}
248+
}
249+
},
250+
"telephoneNumber": {
251+
"type": "string",
252+
"format": "tel",
253+
"title": "Telephone Number",
254+
"minLength": 3,
255+
"ory.sh/kratos": {
256+
"credentials": {
257+
"password": {
258+
"identifier": true
259+
},
260+
"code": {
261+
"identifier": true,
262+
"via": "sms"
263+
}
264+
},
265+
"verification": {
266+
"via": "sms"
267+
},
268+
"recovery": {
269+
"via": "sms"
270+
}
271+
}
272+
}
273+
},
274+
"required": ["email"],
275+
"additionalProperties": false
276+
}
277+
}
278+
}
279+
```
280+
207281
### Attempted recovery notifications
208282

209283
When this option is on and users attempt to initiate recovery for unregistered addresses, the system sends an attempted recovery
210284
notification to the email address that was used in the attempt. This prevents account enumeration attacks as explained in this
211285
[blog post by Troy Hunt](https://www.troyhunt.com/website-enumeration-insanity-how-our-personal-data-is-leaked/). By default, this
212286
feature is disabled in newly created Ory Network projects.
213287

214-
Follow these steps to enable sending attempted recovery notifications:
288+
For cost reasons, the attempted recovery notification does not apply to SMS. An attempt to recover an account using an incorrect
289+
phone number will not trigger an SMS message.
290+
291+
Follow these steps to send attempted recovery notification emails:
215292

216293
```mdx-code-block
217294
<Tabs groupId="console-or-cli">
@@ -260,12 +337,13 @@ Go to <ConsoleLink route="project.recovery" /> and toggle **Notify unknown recip
260337
</Tabs>
261338
```
262339

263-
### Email templates
340+
### Templates
264341

265-
Ory Identities comes with default email templates for recovery flows.
342+
Ory Identities comes with default templates for recovery flows.
266343

267344
You can replace the defaults and customize the messages to match the look and feel of your solution. Read the
268-
[email templates documentation](../../emails-sms/05_custom-email-templates.mdx) to learn more.
345+
[email templates documentation](../../emails-sms/05_custom-email-templates.mdx) and
346+
[SMS templates documentation](../../emails-sms/10_sending-sms.mdx#templates) to learn more.
269347

270348
## Invalidate other sessions
271349

@@ -324,11 +402,11 @@ Learn how to [add and configure hooks for self-service user flows](../../hooks/0
324402

325403
## Fallback recovery address
326404

327-
In some scenarios, users may want to recover their account using a different email address than the one they used to register, for
328-
example if they no longer have access to the original email address. To use two (or more) recovery email addresses, you need to
329-
define a secondary email field, such as `email_secondary` in the traits section of the identity schema. This field will serve as
330-
the fallback email address for account recovery. Read more about identity schemas
331-
[here](../../manage-identities/05_identity-schema.mdx).
405+
A user may need a fallback recovery address if they lose access to the address used for registration.
406+
407+
To enable this, define a secondary field, such as email_secondary, in the traits section of your
408+
[identity schema](../../manage-identities/05_identity-schema.mdx). This field will serve as the alternative address for account
409+
recovery.
332410

333411
This is an example of an identity schema with a secondary email address:
334412

@@ -400,6 +478,10 @@ In this schema, you define both `email` and `email_secondary` fields as recovery
400478
messages to both addresses when the recovery flow is initiated. The user should provide the `email_secondary` field during
401479
registration or update it later in their account settings so it can be used in the recovery process.
402480

481+
This is different from the scenario where a user has multiple recovery addresses of different types, such as one email address and
482+
one phone number. In that case, the user is prompted to choose which address to use, and a recovery message is sent to only the
483+
one they select.
484+
403485
## Native recovery flows
404486

405487
Ory Identities supports recovery flows in native applications. This allows you to build a native application that allows the user

0 commit comments

Comments
 (0)