-
Notifications
You must be signed in to change notification settings - Fork 281
feat(auth): Add WebAuthn/passkey support across all platforms #6812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
ahmedhamouda78
wants to merge
17
commits into
aws-amplify:main
from
ahmedhamouda78:feat/add-passkey-support
Closed
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
889c012
feat(auth): Add WebAuthn/passkey support across all platforms
100b571
Merge branch 'main' into feat/add-passkey-support
82db587
feat(auth): Add WebAuthn pre-sign-up trigger handler and deployment c…
7b78ed6
test(auth): Fix linting issues and type safety in WebAuthn tests
fa8024b
style(auth): Format code and reorganize exports for consistency
508be28
feat(auth): Add WebAuthn support to auth outputs and sign-in steps
69e5963
style(auth): Fix linting issues and import ordering in WebAuthn platf…
37c76f3
fix(passkey): fix failing build
ahmedhamouda78 8ba782c
Merge branch 'main' into feat/add-passkey-support
61b819e
Merge branch 'main' into feat/add-passkey-support
644cef0
fix(passkey): fix android unit test
ahmedhamouda78 e3dfb5c
fix(passkey): regenrate passkey snapshots
3013762
fix(passkey): restore goldens
ahmedhamouda78 1532f52
Merge branch 'main' into feat/add-passkey-support
5dc8f84
fix(passkey): fix macOS crash by excluding it from method channel ASF…
39eb293
fix(passkey): load libfido2.so.1 on Linux for runtime environments
386385a
fix(auth): consolidate pigeon helper functions and update macOS deplo…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| amplify_outputs.dart | ||
| .amplify |
4 changes: 4 additions & 0 deletions
4
infra-gen2/backends/auth/webauthn/amplify/auth/pre-sign-up-handler.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| import { PreSignUpTriggerHandler } from "aws-lambda"; | ||
| import { preSignUpTriggerHandler } from "infra-common"; | ||
|
|
||
| export const handler: PreSignUpTriggerHandler = preSignUpTriggerHandler; |
28 changes: 28 additions & 0 deletions
28
infra-gen2/backends/auth/webauthn/amplify/auth/resource.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { defineAuth, defineFunction } from "@aws-amplify/backend"; | ||
|
|
||
| export const preSignUp = defineFunction({ | ||
| name: "pre-sign-up", | ||
| entry: "./pre-sign-up-handler.ts", | ||
| }); | ||
|
|
||
| export const auth = defineAuth({ | ||
| loginWith: { | ||
| email: { otpLogin: true }, | ||
| phone: { otpLogin: true }, | ||
| webAuthn: true, // relyingPartyId auto-resolves to localhost in sandbox | ||
| }, | ||
| passwordlessOptions: { | ||
| preferredChallenge: "WEB_AUTHN" | ||
| }, | ||
| userAttributes: { | ||
| phoneNumber: { | ||
| required: false | ||
| } | ||
| }, | ||
| triggers: { | ||
| preSignUp, | ||
| }, | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { defineBackend } from "@aws-amplify/backend"; | ||
| import { auth } from "./auth/resource"; | ||
|
|
||
| defineBackend({ | ||
| auth, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| { "type": "module" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "target": "es2022", | ||
| "module": "es2022", | ||
| "moduleResolution": "bundler", | ||
| "resolveJsonModule": true, | ||
| "esModuleInterop": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "strict": true, | ||
| "skipLibCheck": true, | ||
| "paths": { | ||
| "$amplify/*": [ | ||
| "../.amplify/generated/*" | ||
| ] | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "name": "webauthn", | ||
| "version": "1.0.0", | ||
| "main": "index.js" | ||
| } | ||
|
Comment on lines
+1
to
+5
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please register it here: |
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
packages/amplify_core/lib/src/config/amplify_outputs/auth/passwordless_outputs.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import 'package:amplify_core/amplify_core.dart'; | ||
|
|
||
| /// Passwordless authentication configuration from Amplify outputs. | ||
| class PasswordlessOutputs { | ||
| const PasswordlessOutputs({ | ||
| this.emailOtpEnabled = false, | ||
| this.smsOtpEnabled = false, | ||
| this.webAuthnEnabled = false, | ||
| this.preferredChallenge, | ||
| }); | ||
|
|
||
| factory PasswordlessOutputs.fromJson(Map<String, Object?> json) { | ||
| return PasswordlessOutputs( | ||
| emailOtpEnabled: json['email_otp_enabled'] as bool? ?? false, | ||
| smsOtpEnabled: json['sms_otp_enabled'] as bool? ?? false, | ||
| webAuthnEnabled: json['web_authn'] != null, | ||
| preferredChallenge: _parseChallenge( | ||
| json['preferred_challenge'] as String?, | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| static AuthFactorType? _parseChallenge(String? value) { | ||
| switch (value) { | ||
| case 'WEB_AUTHN': | ||
| return AuthFactorType.webAuthn; | ||
| case 'EMAIL_OTP': | ||
| return AuthFactorType.emailOtp; | ||
| case 'SMS_OTP': | ||
| return AuthFactorType.smsOtp; | ||
| case 'PASSWORD': | ||
| case 'PASSWORD_SRP': | ||
| return AuthFactorType.password; | ||
| default: | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| final bool emailOtpEnabled; | ||
| final bool smsOtpEnabled; | ||
| final bool webAuthnEnabled; | ||
|
|
||
| /// The preferred first-factor challenge from the backend config. | ||
| final AuthFactorType? preferredChallenge; | ||
|
|
||
| /// Returns all enabled passwordless methods. | ||
| List<AuthFactorType> get enabledMethods => [ | ||
| if (webAuthnEnabled) AuthFactorType.webAuthn, | ||
| if (emailOtpEnabled) AuthFactorType.emailOtp, | ||
| if (smsOtpEnabled) AuthFactorType.smsOtp, | ||
| ]; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/amplify_core/lib/src/types/auth/credential/auth_webauthn_credential.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import 'package:aws_common/aws_common.dart'; | ||
| import 'package:meta/meta.dart'; | ||
|
|
||
| /// {@category Auth} | ||
| /// {@template amplify_core.auth_webauthn_credential} | ||
| /// Common interface for WebAuthn/passkey credentials registered with an authentication provider. | ||
| /// {@endtemplate} | ||
| @immutable | ||
| abstract class AuthWebAuthnCredential | ||
| with AWSSerializable<Map<String, Object?>> { | ||
| /// {@macro amplify_core.auth_webauthn_credential} | ||
| const AuthWebAuthnCredential(); | ||
|
|
||
| /// Unique identifier for this credential. | ||
| String get credentialId; | ||
|
|
||
| /// User-assigned friendly name for the credential (e.g., "My iPhone"). | ||
| String? get friendlyName; | ||
|
|
||
| /// Relying party identifier (typically the domain). | ||
| String get relyingPartyId; | ||
|
|
||
| /// Type of authenticator attachment (e.g., "platform", "cross-platform"). | ||
| String? get authenticatorAttachment; | ||
|
|
||
| /// List of transport types supported by the authenticator (e.g., "usb", "nfc", "ble", "internal"). | ||
| List<String>? get authenticatorTransports; | ||
|
|
||
| /// Date and time when the credential was created. | ||
| DateTime get createdAt; | ||
|
|
||
| /// Converts the instance to a JSON map. | ||
| @override | ||
| Map<String, Object?> toJson(); | ||
|
|
||
| @override | ||
| String toString() { | ||
| return 'AuthWebAuthnCredential{credentialId=$credentialId, friendlyName=$friendlyName, relyingPartyId=$relyingPartyId, createdAt=$createdAt}'; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need account verification here? If so, habe a look at this:
amplify-flutter/infra-gen2/backends/kinesis/main/amplify/auth/resource.ts
Line 3 in f431109