Skip to content

Commit ab617e0

Browse files
authored
docs: document recovery v2 (recovery via SMS) (#2238)
1 parent 9aa8433 commit ab617e0

File tree

2 files changed

+62
-7
lines changed

2 files changed

+62
-7
lines changed

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

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ configure account recovery in your Ory project.
2828
<TabItem value="console">
2929
```
3030

31-
**Enable and configure account recovery**
31+
### Enable and configure account recovery
3232

3333
1. Log in to your [Ory Console](https://console.ory.sh/)
3434
2. Select your workspace and project
@@ -42,11 +42,21 @@ configure account recovery in your Ory project.
4242
</BrowserWindow>
4343
```
4444

45-
**Recovery strategy**
45+
### Enable SMS account recovery
46+
47+
Enable the feature flag `choose_recovery_address` to be able to send a recovery code via SMS.
48+
49+
1. Log in to your [Ory Console](https://console.ory.sh/)
50+
2. Select your workspace and project
51+
3. Navigate to <ConsoleLink route="project.settings.advanced" />
52+
4. Toggle "Receive a recovery code via SMS" to 'on'
53+
5. Click **Save**
54+
55+
### Recovery strategy
4656

4757
You can choose between the following recovery strategies:
4858

49-
- One-time passwords: Sends a one-time code via email
59+
- One-time passwords: Sends a one-time code via email, or SMS (with the feature flag `choose_recovery_address` enabled)
5060
- Magic link: Sends a recovery link via email
5161

5262
1. In the Account recovery section
@@ -68,7 +78,7 @@ import BrowserWindow from "@site/src/theme/BrowserWindow"
6878
<TabItem value="cli">
6979
```
7080

71-
**Download your current configuration**
81+
### Download your current configuration
7282

7383
First, get your current identity configuration:
7484

@@ -81,9 +91,14 @@ ory list projects --workspace <workspace-id>
8191

8292
# Get the configuration
8393
ory get identity-config --project <project-id> --workspace <workspace-id> --format yaml > identity-config.yaml
94+
95+
# Toggle the feature flag 'on'
96+
ory patch project --replace '/services/identity/config/feature_flags/choose_recovery_address=true'
97+
98+
ory get project --format='jsonpointer=/services/identity/config/feature_flags/choose_recovery_address'
8499
```
85100

86-
**Edit recovery configuration**
101+
### Edit recovery configuration
87102

88103
Add or modify the recovery section in your configuration file:
89104

@@ -102,7 +117,7 @@ selfservice:
102117
notify_unknown_recipients: false # Define if the system sends automated recovery notifications to unknown email addresses.
103118
```
104119
105-
**Update your configuration**
120+
### Update your configuration
106121
107122
After editing, update your configuration:
108123
@@ -135,9 +150,43 @@ When a user initiates account recovery:
135150

136151
### User flow
137152

153+
When the feature flag `choose_recovery_address` is enabled and the `code` method is in use:
154+
155+
1. They enter their email address on the recovery page
156+
2. If they have multiple recovery addresses, they can pick which one to use
157+
3. They receive a one-time code on their recovery address, via email or SMS, depending on the type of address
158+
4. After entering the code, they're prompted to set a new password
159+
5. Once completed, they regain access to their account with a new password
160+
161+
---
162+
163+
When the feature flag `choose_recovery_address` is disabled, or the `link` method is in use:
164+
138165
1. They enter their email address on the recovery page
139166
2. They receive either:
140167
- A recovery link via email if using the `link` method
141168
- A one-time code via email if using the `code` method
142169
3. After clicking the link or entering the code, they're prompted to set a new password
143170
4. Once completed, they regain access to their account with a new password
171+
172+
## What happens if the address provided by the user is 'wrong'?
173+
174+
If the address is malformed, or well-formed but not registered as a recovery address for this user:
175+
176+
- The recovery flow will not complete. This means that no recovery code will be generated and sent.
177+
- The UI will look indistinguishable from the case of a valid recovery address provided. That is to prevent an attacker from
178+
probing the system to discover which addresses are registered.
179+
- If the address is a valid email address but not registered as a recovery address for this user, and the configuration value
180+
`selfservice.flows.recovery.notify_unknown_recipients` is enabled, an email will be sent to this address with this wording (this
181+
can be [customized](../../kratos/emails-sms/sending-emails-smtp#send-emails-using-an-http-server)):
182+
> Hi,
183+
>
184+
> you (or someone else) entered this email address when trying to recover access to an account.
185+
>
186+
> However, this email address is not on our database of registered users and therefore the attempt has failed.
187+
>
188+
> If this was you, check if you signed up using a different address.
189+
>
190+
> 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
192+
`selfservice.flows.recovery.notify_unknown_recipients` is disabled, nothing will be sent.

docs/kratos/emails-sms/10_sending-sms.mdx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Read the [Jsonnet documentation](../../kratos/reference/jsonnet.mdx) to learn mo
9797

9898
## Templates
9999

100-
Only the `verification_code` and `login_code` templates support an SMS variant. Use the CLI to configure it:
100+
Only the `recovery_code`, `verification_code`, and `login_code` templates support an SMS variant. Use the CLI to configure it:
101101

102102
```mdx-code-block
103103
<Tabs groupId="console-or-cli">
@@ -132,6 +132,12 @@ Only the `verification_code` and `login_code` templates support an SMS variant.
132132
sms:
133133
body:
134134
plaintext: "base64://WW91ciBsb2dpbiBjb2RlIGlzOiB7eyAuTG9naW5Db2RlIH19"
135+
136+
recovery_code:
137+
valid:
138+
sms:
139+
body:
140+
plaintext: "base64://WW91ciByZWNvdmVyeSBjb2RlIGlzOiB7eyAuUmVjb3ZlcnlDb2RlIH19CgpAe3sgLlJlcXVlc3RVUkxEb21haW4gfX0gI3t7IC5SZWNvdmVyeUNvZGUgfX0K"
135141
```
136142
137143
3. Update the Ory Identities configuration using the file you worked with:

0 commit comments

Comments
 (0)