You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -34,15 +34,40 @@ Amplify supports the use of passwordless authentication flows using the followin
34
34
-[WebAuthn passkey](#webauthn-passkey)
35
35
36
36
Passwordless authentication removes the security risks and user friction associated with traditional passwords.
37
-
{/* add more color */}
38
37
39
-
<Calloutwarning>
38
+
## Configure passwordless authentication
40
39
41
-
**Warning:** Passwordless configuration is currently not available in `defineAuth`. We are currently working towards enabling support for passwordless configurations. [Visit the GitHub issue to track the progress](https://github.com/aws-amplify/amplify-backend/issues/2276)
40
+
You can enable passwordless authentication methods directly in your `defineAuth` configuration. Passwordless methods are used alongside traditional password-based authentication, giving users multiple options to sign in.
42
41
43
-
</Callout>
42
+
```ts title="amplify/auth/resource.ts"
43
+
import { defineAuth } from'@aws-amplify/backend';
44
44
45
-
Learn how to enable passwordless sign-in flows by [overriding the Cognito UserPool to enable the sign-in methods below](/[platform]/build-a-backend/auth/modify-resources-with-cdk/#override-cognito-userpool-to-enable-passwordless-sign-in-methods).
45
+
exportconst auth =defineAuth({
46
+
loginWith: {
47
+
email: {
48
+
otpLogin: true// Enable email OTP
49
+
}
50
+
}
51
+
});
52
+
```
53
+
54
+
You can enable multiple passwordless methods simultaneously:
55
+
56
+
```ts title="amplify/auth/resource.ts"
57
+
import { defineAuth } from'@aws-amplify/backend';
58
+
59
+
exportconst auth =defineAuth({
60
+
loginWith: {
61
+
email: {
62
+
otpLogin: true// Enable email OTP
63
+
},
64
+
phone: {
65
+
otpLogin: true// Enable SMS OTP
66
+
},
67
+
webAuthn: true// Enable WebAuthn passkeys
68
+
}
69
+
});
70
+
```
46
71
47
72
{/* need a section about what a "preferred" factor is */}
48
73
@@ -54,23 +79,21 @@ SMS-based authentication uses phone numbers as the identifier and text messages
54
79
2. They receive a text message with a time-limited code
55
80
3. After the user enters their code they are authenticated
Enable WebAuthn passkeys in your auth configuration. The simplest configuration uses automatic relying party ID resolution:
151
+
152
+
```ts title="amplify/auth/resource.ts"
153
+
import { defineAuth } from'@aws-amplify/backend';
154
+
155
+
exportconst auth =defineAuth({
156
+
loginWith: {
157
+
email: true, // Users need a sign-up method
158
+
webAuthn: true// Automatically resolves relying party ID
159
+
}
160
+
});
161
+
```
162
+
163
+
When `webAuthn: true` is used, the relying party ID is automatically resolved:
164
+
- In **sandbox** environments: resolves to `localhost`
165
+
- In **branch** deployments: resolves to your Amplify app domain (e.g., `[branch].[appId].amplifyapp.com`)
166
+
167
+
For production environments or custom domains, specify the relying party ID explicitly:
168
+
169
+
```ts title="amplify/auth/resource.ts"
170
+
import { defineAuth } from'@aws-amplify/backend';
171
+
172
+
exportconst auth =defineAuth({
173
+
loginWith: {
174
+
email: true,
175
+
webAuthn: {
176
+
relyingPartyId: 'example.com',
177
+
userVerification: 'required'// or 'preferred' (default)
178
+
}
179
+
}
180
+
});
181
+
```
130
182
131
-
</InlineFilter>
132
183
<InlineFilterfilters={["android"]}>
133
184
134
185
You can read more about how passkeys work in the [Android developer docs](https://developer.android.com/design/ui/mobile/guides/patterns/passkeys).
@@ -140,7 +191,7 @@ Registering a passkey is supported on Android 9 (API level 28) and above.
140
191
Using passkeys with Amplify requires following these steps:
141
192
142
193
1. Deploy a Digital Asset Links file to your website granting the `get_login_creds` permission to your application. See the [Credential Manager documentation](https://developer.android.com/identity/sign-in/credential-manager#add-support-dal) for more details about this file.
143
-
1.[Configure your Amazon Cognito user pool](/[platform]/build-a-backend/auth/modify-resources-with-cdk/#override-cognito-userpool-to-enable-passwordless-sign-in-methods) with `WEB_AUTHN` as an allowed first factor, and specify your website domain as the `WebAuthnRelyingPartyID`.
194
+
1. Configure WebAuthn in your `defineAuth` as shown above, specifying your website domain as the `relyingPartyId`.
144
195
1. Use the Amplify Android APIs to first [register a passkey](/[platform]/build-a-backend/auth/manage-users/manage-webauthn-credentials/#associate-webauthn-credentials) and then to [sign in with WebAuthn](/[platform]/build-a-backend/auth/connect-your-frontend/sign-in/#webauthn-passkeys).
145
196
146
197
</InlineFilter>
@@ -157,3 +208,63 @@ Using passkeys with Amplify requires following these steps:
157
208
Passwordless authentication with WebAuthn requires associating one or more credentials with the user's Amazon Cognito account. Amplify provides APIs that integrate with each platform's local authenticator to easily create, view, and delete these credential associations.
158
209
159
210
[Learn more about managing WebAuthn credentials](/[platform]/build-a-backend/auth/manage-users/manage-webauthn-credentials).
211
+
212
+
## Passwordless authentication
213
+
214
+
When you enable passwordless authentication methods, traditional password authentication remains available. This gives users flexibility to choose their preferred authentication method:
In this configuration, users can authenticate using either:
229
+
- Email and password (traditional)
230
+
- Email OTP (passwordless)
231
+
232
+
You can enable multiple passwordless methods to give users even more options:
233
+
234
+
```ts title="amplify/auth/resource.ts"
235
+
import { defineAuth } from'@aws-amplify/backend';
236
+
237
+
exportconst auth =defineAuth({
238
+
loginWith: {
239
+
email: {
240
+
otpLogin: true
241
+
},
242
+
phone: {
243
+
otpLogin: true
244
+
},
245
+
webAuthn: {
246
+
relyingPartyId: 'example.com'
247
+
}
248
+
}
249
+
});
250
+
```
251
+
252
+
In this configuration, users can authenticate using:
253
+
- Email and password
254
+
- Email OTP
255
+
- Phone and password
256
+
- SMS OTP
257
+
- WebAuthn passkeys
258
+
259
+
<Calloutinfo>
260
+
261
+
When using WebAuthn, users still need a way to initially sign up (email or phone). WebAuthn credentials are then associated with their account for future sign-ins.
262
+
263
+
</Callout>
264
+
265
+
## Next steps
266
+
267
+
-[Learn how to implement passwordless sign-in in your application](/[platform]/build-a-backend/auth/connect-your-frontend/sign-in/)
268
+
-[Configure email settings for Email OTP](/[platform]/build-a-backend/auth/moving-to-production/#email)
269
+
-[Configure SMS settings for SMS OTP](/[platform]/build-a-backend/auth/moving-to-production/#sms)
Copy file name to clipboardExpand all lines: src/pages/[platform]/build-a-backend/auth/modify-resources-with-cdk/index.mdx
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,13 @@ cfnUserPool.policies = {
65
65
66
66
## Override Cognito UserPool to enable passwordless sign-in methods
67
67
68
-
You can modify the underlying Cognito user pool resource to enable sign in with passwordless methods. [Learn more about passwordless sign-in methods](/[platform]/build-a-backend/auth/concepts/passwordless/).
68
+
<Calloutinfo>
69
+
70
+
**Recommended approach:** Passwordless authentication can now be configured directly in `defineAuth` without requiring CDK overrides. [Learn how to configure passwordless authentication](/[platform]/build-a-backend/auth/concepts/passwordless/).
71
+
72
+
</Callout>
73
+
74
+
For advanced use cases, you can still modify the underlying Cognito user pool resource to enable sign in with passwordless methods using CDK overrides. [Learn more about passwordless sign-in methods](/[platform]/build-a-backend/auth/concepts/passwordless/).
69
75
70
76
You can also read more about how passwordless authentication flows are implemented in the [Cognito documentation](https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-authentication-flow-methods.html).
By default, your auth resource is scaffolded using `email` as the default login mechanism. You can also configure your auth resource to allow signing in with phone numbers or an external provider such as Google, Facebook, Amazon, or Sign in with Apple.
50
+
By default, your auth resource is scaffolded using `email` as the default login mechanism. You can also configure your auth resource to allow signing in with:
51
+
52
+
- Phone numbers
53
+
- External providers (Google, Facebook, Amazon, or Sign in with Apple)
-[Passwordless authentication](/[platform]/build-a-backend/auth/concepts/passwordless/) (Email OTP, SMS OTP, or WebAuthn passkeys)
56
+
</InlineFilter>
51
57
52
58
<Calloutinfo>
53
59
54
60
**Note:** At a minimum you will need to pass a `loginWith` value to set up how your users sign in to your app. Signing in with email and password is configured by default if you do not provide any value.
0 commit comments